|
| 1 | +package audit_trail |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + |
| 6 | + "github.com/scaleway/scaleway-cli/v2/core" |
| 7 | + audit_trail "github.com/scaleway/scaleway-sdk-go/api/audit_trail/v1alpha1" |
| 8 | +) |
| 9 | + |
| 10 | +func eventListBuilder(c *core.Command) *core.Command { |
| 11 | + c.View = &core.View{ |
| 12 | + Fields: []*core.ViewField{ |
| 13 | + { |
| 14 | + Label: "Recorded At", |
| 15 | + FieldName: "RecordedAt", |
| 16 | + }, |
| 17 | + { |
| 18 | + Label: "Name", |
| 19 | + FieldName: "Resource.Name", |
| 20 | + }, |
| 21 | + { |
| 22 | + Label: "StatusCode", |
| 23 | + FieldName: "StatusCode", |
| 24 | + }, |
| 25 | + { |
| 26 | + Label: "MethodName", |
| 27 | + FieldName: "MethodName", |
| 28 | + }, |
| 29 | + { |
| 30 | + Label: "Principal", |
| 31 | + FieldName: "Principal.ID", |
| 32 | + }, |
| 33 | + { |
| 34 | + Label: "SourceIP", |
| 35 | + FieldName: "SourceIP", |
| 36 | + }, |
| 37 | + { |
| 38 | + Label: "ProjectID", |
| 39 | + FieldName: "ProjectID", |
| 40 | + }, |
| 41 | + { |
| 42 | + Label: "ProductName", |
| 43 | + FieldName: "ProductName", |
| 44 | + }, |
| 45 | + { |
| 46 | + Label: "RequestBody", |
| 47 | + FieldName: "RequestBody", |
| 48 | + }, |
| 49 | + { |
| 50 | + Label: "RequestID", |
| 51 | + FieldName: "RequestID", |
| 52 | + }, |
| 53 | + { |
| 54 | + Label: "User-Agent", |
| 55 | + FieldName: "UserAgent", |
| 56 | + }, |
| 57 | + { |
| 58 | + Label: "ID", |
| 59 | + FieldName: "ID", |
| 60 | + }, |
| 61 | + { |
| 62 | + Label: "ServiceName", |
| 63 | + FieldName: "ServiceName", |
| 64 | + }, |
| 65 | + { |
| 66 | + Label: "Type", |
| 67 | + FieldName: "Resource.Type", |
| 68 | + }, |
| 69 | + { |
| 70 | + Label: "ResourceID", |
| 71 | + FieldName: "Resource.ID", |
| 72 | + }, |
| 73 | + { |
| 74 | + Label: "Resource Created At", |
| 75 | + FieldName: "Resource.CreatedAt", |
| 76 | + }, |
| 77 | + { |
| 78 | + Label: "Resource Updated At", |
| 79 | + FieldName: "Resource.UpdatedAt", |
| 80 | + }, |
| 81 | + }, |
| 82 | + } |
| 83 | + |
| 84 | + c.AddInterceptors(func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (interface{}, error) { |
| 85 | + originalRes, err := runner(ctx, argsI) |
| 86 | + if err != nil { |
| 87 | + return nil, err |
| 88 | + } |
| 89 | + |
| 90 | + eventsResponse := originalRes.(*audit_trail.ListEventsResponse) |
| 91 | + |
| 92 | + return eventsResponse.Events, nil |
| 93 | + }) |
| 94 | + |
| 95 | + return c |
| 96 | +} |
0 commit comments