Skip to content

Commit 6a3bd30

Browse files
feat(audit_trail): add support for v1alpha1 (scaleway#4324)
Co-authored-by: Rémy Léone <[email protected]>
1 parent 74ffd8c commit 6a3bd30

9 files changed

+291
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Retrieve the list of Audit Trail events for a Scaleway Organization and/or Project. You must specify the `organization_id` and optionally, the `project_id`.
4+
5+
USAGE:
6+
scw audit-trail event list [arg=value ...]
7+
8+
ARGS:
9+
[project-id] (Optional) ID of the Project containing the Audit Trail events
10+
[resource-type] (Optional) Returns a paginated list of Scaleway resources' features (unknown_type | secm_secret | secm_secret_version | kube_cluster | kube_pool | kube_node | kube_acl)
11+
[method-name] (Optional) Name of the method or the API call performed
12+
[status] (Optional) HTTP status code of the request. Returns either `200` if the request was successful or `403` if the permission was denied
13+
[recorded-after] (Optional) The `recorded_after` parameter defines the earliest timestamp from which Audit Trail events are retrieved. Returns `one hour ago` by default
14+
[recorded-before] (Optional) The `recorded_before` parameter defines the latest timestamp up to which Audit Trail events are retrieved. Returns `now` by default
15+
[order-by] (recorded_at_desc | recorded_at_asc)
16+
[page-size]
17+
[page-token]
18+
[product-name] (Optional) Name of the Scaleway resource in a hyphenated format
19+
[organization-id] Organization ID to use. If none is passed the default organization ID will be used
20+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams)
21+
22+
FLAGS:
23+
-h, --help help for list
24+
25+
GLOBAL FLAGS:
26+
-c, --config string The path to the config file
27+
-D, --debug Enable debug mode
28+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
29+
-p, --profile string The config profile to use
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Represent an entry in the Audit Trail.
4+
5+
USAGE:
6+
scw audit-trail event <command>
7+
8+
AVAILABLE COMMANDS:
9+
list List events
10+
11+
FLAGS:
12+
-h, --help help for event
13+
14+
GLOBAL FLAGS:
15+
-c, --config string The path to the config file
16+
-D, --debug Enable debug mode
17+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
18+
-p, --profile string The config profile to use
19+
20+
Use "scw audit-trail event [command] --help" for more information about a command.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Retrieve the list of Scaleway resources for which you have Audit Trail events.
4+
5+
USAGE:
6+
scw audit-trail product list [arg=value ...]
7+
8+
ARGS:
9+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams)
10+
11+
FLAGS:
12+
-h, --help help for list
13+
14+
GLOBAL FLAGS:
15+
-c, --config string The path to the config file
16+
-D, --debug Enable debug mode
17+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
18+
-p, --profile string The config profile to use
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Product integrated with Audit Trail.
4+
5+
USAGE:
6+
scw audit-trail product <command>
7+
8+
AVAILABLE COMMANDS:
9+
list Retrieve the list of Scaleway resources for which you have Audit Trail events
10+
11+
FLAGS:
12+
-h, --help help for product
13+
14+
GLOBAL FLAGS:
15+
-c, --config string The path to the config file
16+
-D, --debug Enable debug mode
17+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
18+
-p, --profile string The config profile to use
19+
20+
Use "scw audit-trail product [command] --help" for more information about a command.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
This API allows you to ensure accountability and security by recording events and changes performed within your Scaleway Organization.
4+
5+
USAGE:
6+
scw audit-trail <command>
7+
8+
AVAILABLE COMMANDS:
9+
event Represent an entry in the Audit Trail
10+
product Product integrated with Audit Trail
11+
12+
FLAGS:
13+
-h, --help help for audit-trail
14+
15+
GLOBAL FLAGS:
16+
-c, --config string The path to the config file
17+
-D, --debug Enable debug mode
18+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
19+
-p, --profile string The config profile to use
20+
21+
Use "scw audit-trail [command] --help" for more information about a command.

cmd/scw/testdata/test-main-usage-usage.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ USAGE:
66
AVAILABLE COMMANDS:
77
account This API allows you to manage your Scaleway Projects
88
apple-silicon Apple silicon API
9+
audit-trail This API allows you to ensure accountability and security by recording events and changes performed within your Scaleway Organization.
910
autocomplete Autocomplete related commands
1011
baremetal Elastic Metal API
1112
billing This API allows you to manage and query your Scaleway billing and consumption

commands/commands.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
accountv3 "github.com/scaleway/scaleway-cli/v2/internal/namespaces/account/v3"
88
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/alias"
99
applesilicon "github.com/scaleway/scaleway-cli/v2/internal/namespaces/applesilicon/v1alpha1"
10+
audit_trail "github.com/scaleway/scaleway-cli/v2/internal/namespaces/audit_trail/v1alpha1"
1011
autocompleteNamespace "github.com/scaleway/scaleway-cli/v2/internal/namespaces/autocomplete"
1112
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/baremetal/v1"
1213
billing "github.com/scaleway/scaleway-cli/v2/internal/namespaces/billing/v2beta1"
@@ -106,6 +107,7 @@ func GetCommands() *core.Commands {
106107
edgeservices.GetCommands(),
107108
login.GetCommands(),
108109
mongodb.GetCommands(),
110+
audit_trail.GetCommands(),
109111
)
110112

111113
if beta {
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
// This file was automatically generated. DO NOT EDIT.
2+
// If you have any remark or suggestion do not hesitate to open an issue.
3+
4+
package audit_trail
5+
6+
import (
7+
"context"
8+
"reflect"
9+
10+
"github.com/scaleway/scaleway-cli/v2/core"
11+
"github.com/scaleway/scaleway-sdk-go/api/audit_trail/v1alpha1"
12+
"github.com/scaleway/scaleway-sdk-go/scw"
13+
)
14+
15+
// always import dependencies
16+
var (
17+
_ = scw.RegionFrPar
18+
)
19+
20+
func GetGeneratedCommands() *core.Commands {
21+
return core.NewCommands(
22+
auditTrailRoot(),
23+
auditTrailEvent(),
24+
auditTrailProduct(),
25+
auditTrailEventList(),
26+
auditTrailProductList(),
27+
)
28+
}
29+
func auditTrailRoot() *core.Command {
30+
return &core.Command{
31+
Short: `This API allows you to ensure accountability and security by recording events and changes performed within your Scaleway Organization.`,
32+
Long: `This API allows you to ensure accountability and security by recording events and changes performed within your Scaleway Organization.`,
33+
Namespace: "audit-trail",
34+
}
35+
}
36+
37+
func auditTrailEvent() *core.Command {
38+
return &core.Command{
39+
Short: `Represent an entry in the Audit Trail`,
40+
Long: `Represent an entry in the Audit Trail.`,
41+
Namespace: "audit-trail",
42+
Resource: "event",
43+
}
44+
}
45+
46+
func auditTrailProduct() *core.Command {
47+
return &core.Command{
48+
Short: `Product integrated with Audit Trail`,
49+
Long: `Product integrated with Audit Trail.`,
50+
Namespace: "audit-trail",
51+
Resource: "product",
52+
}
53+
}
54+
55+
func auditTrailEventList() *core.Command {
56+
return &core.Command{
57+
Short: `List events`,
58+
Long: `Retrieve the list of Audit Trail events for a Scaleway Organization and/or Project. You must specify the ` + "`" + `organization_id` + "`" + ` and optionally, the ` + "`" + `project_id` + "`" + `.`,
59+
Namespace: "audit-trail",
60+
Resource: "event",
61+
Verb: "list",
62+
// Deprecated: false,
63+
ArgsType: reflect.TypeOf(audit_trail.ListEventsRequest{}),
64+
ArgSpecs: core.ArgSpecs{
65+
{
66+
Name: "project-id",
67+
Short: `(Optional) ID of the Project containing the Audit Trail events`,
68+
Required: false,
69+
Deprecated: false,
70+
Positional: false,
71+
},
72+
{
73+
Name: "resource-type",
74+
Short: `(Optional) Returns a paginated list of Scaleway resources' features`,
75+
Required: false,
76+
Deprecated: false,
77+
Positional: false,
78+
EnumValues: []string{"unknown_type", "secm_secret", "secm_secret_version", "kube_cluster", "kube_pool", "kube_node", "kube_acl"},
79+
},
80+
{
81+
Name: "method-name",
82+
Short: `(Optional) Name of the method or the API call performed`,
83+
Required: false,
84+
Deprecated: false,
85+
Positional: false,
86+
},
87+
{
88+
Name: "status",
89+
Short: `(Optional) HTTP status code of the request. Returns either ` + "`" + `200` + "`" + ` if the request was successful or ` + "`" + `403` + "`" + ` if the permission was denied`,
90+
Required: false,
91+
Deprecated: false,
92+
Positional: false,
93+
},
94+
{
95+
Name: "recorded-after",
96+
Short: `(Optional) The ` + "`" + `recorded_after` + "`" + ` parameter defines the earliest timestamp from which Audit Trail events are retrieved. Returns ` + "`" + `one hour ago` + "`" + ` by default`,
97+
Required: false,
98+
Deprecated: false,
99+
Positional: false,
100+
},
101+
{
102+
Name: "recorded-before",
103+
Short: `(Optional) The ` + "`" + `recorded_before` + "`" + ` parameter defines the latest timestamp up to which Audit Trail events are retrieved. Returns ` + "`" + `now` + "`" + ` by default`,
104+
Required: false,
105+
Deprecated: false,
106+
Positional: false,
107+
},
108+
{
109+
Name: "order-by",
110+
Required: false,
111+
Deprecated: false,
112+
Positional: false,
113+
EnumValues: []string{"recorded_at_desc", "recorded_at_asc"},
114+
},
115+
{
116+
Name: "page-size",
117+
Required: false,
118+
Deprecated: false,
119+
Positional: false,
120+
},
121+
{
122+
Name: "page-token",
123+
Required: false,
124+
Deprecated: false,
125+
Positional: false,
126+
},
127+
{
128+
Name: "product-name",
129+
Short: `(Optional) Name of the Scaleway resource in a hyphenated format`,
130+
Required: false,
131+
Deprecated: false,
132+
Positional: false,
133+
},
134+
core.OrganizationIDArgSpec(),
135+
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
136+
},
137+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
138+
request := args.(*audit_trail.ListEventsRequest)
139+
140+
client := core.ExtractClient(ctx)
141+
api := audit_trail.NewAPI(client)
142+
return api.ListEvents(request)
143+
144+
},
145+
}
146+
}
147+
148+
func auditTrailProductList() *core.Command {
149+
return &core.Command{
150+
Short: `Retrieve the list of Scaleway resources for which you have Audit Trail events`,
151+
Long: `Retrieve the list of Scaleway resources for which you have Audit Trail events.`,
152+
Namespace: "audit-trail",
153+
Resource: "product",
154+
Verb: "list",
155+
// Deprecated: false,
156+
ArgsType: reflect.TypeOf(audit_trail.ListProductsRequest{}),
157+
ArgSpecs: core.ArgSpecs{
158+
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
159+
},
160+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
161+
request := args.(*audit_trail.ListProductsRequest)
162+
163+
client := core.ExtractClient(ctx)
164+
api := audit_trail.NewAPI(client)
165+
return api.ListProducts(request)
166+
167+
},
168+
}
169+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package audit_trail
2+
3+
import (
4+
"github.com/scaleway/scaleway-cli/v2/core"
5+
)
6+
7+
func GetCommands() *core.Commands {
8+
cmds := GetGeneratedCommands()
9+
10+
return cmds
11+
}

0 commit comments

Comments
 (0)