Skip to content

Commit

Permalink
Merge branch 'master' into v1.6212.0
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone authored Mar 10, 2025
2 parents 6bbc1bc + 76bdc1e commit 7cbea77
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/namespaces/audit_trail/v1alpha1/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ import (
func GetCommands() *core.Commands {
cmds := GetGeneratedCommands()

cmds.MustFind("audit-trail", "event", "list").Override(eventListBuilder)

return cmds
}
96 changes: 96 additions & 0 deletions internal/namespaces/audit_trail/v1alpha1/custom_event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package audit_trail

import (
"context"

"github.com/scaleway/scaleway-cli/v2/core"
audit_trail "github.com/scaleway/scaleway-sdk-go/api/audit_trail/v1alpha1"
)

func eventListBuilder(c *core.Command) *core.Command {
c.View = &core.View{
Fields: []*core.ViewField{
{
Label: "Recorded At",
FieldName: "RecordedAt",
},
{
Label: "Name",
FieldName: "Resource.Name",
},
{
Label: "StatusCode",
FieldName: "StatusCode",
},
{
Label: "MethodName",
FieldName: "MethodName",
},
{
Label: "Principal",
FieldName: "Principal.ID",
},
{
Label: "SourceIP",
FieldName: "SourceIP",
},
{
Label: "ProjectID",
FieldName: "ProjectID",
},
{
Label: "ProductName",
FieldName: "ProductName",
},
{
Label: "RequestBody",
FieldName: "RequestBody",
},
{
Label: "RequestID",
FieldName: "RequestID",
},
{
Label: "User-Agent",
FieldName: "UserAgent",
},
{
Label: "ID",
FieldName: "ID",
},
{
Label: "ServiceName",
FieldName: "ServiceName",
},
{
Label: "Type",
FieldName: "Resource.Type",
},
{
Label: "ResourceID",
FieldName: "Resource.ID",
},
{
Label: "Resource Created At",
FieldName: "Resource.CreatedAt",
},
{
Label: "Resource Updated At",
FieldName: "Resource.UpdatedAt",
},
},
}

c.AddInterceptors(func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (interface{}, error) {
originalRes, err := runner(ctx, argsI)
if err != nil {
return nil, err
}

eventsResponse := originalRes.(*audit_trail.ListEventsResponse)

return eventsResponse.Events, nil
})

return c
}

0 comments on commit 7cbea77

Please sign in to comment.