Skip to content

Commit 60be459

Browse files
authored
feat(account/v3): add support for account/v3 (#3289)
1 parent fb5705d commit 60be459

3 files changed

Lines changed: 226 additions & 3 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require (
2424
github.com/moby/buildkit v0.11.6
2525
github.com/opencontainers/go-digest v1.0.0
2626
github.com/pkg/errors v0.9.1
27-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.18.0.20230710160943-efc922e1f661
27+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.19.0.20230717114303-9b6e07d6384b
2828
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
2929
github.com/spf13/cobra v1.7.0
3030
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,8 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj
497497
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
498498
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
499499
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
500-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.18.0.20230710160943-efc922e1f661 h1:/FNBbwxEzMriXGudqXTGOg0nIeNO+0xpqXChZk6auBE=
501-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.18.0.20230710160943-efc922e1f661/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
500+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.19.0.20230717114303-9b6e07d6384b h1:b5kG1Uzb4Fst6BoLXsgowQHj6WOkECIj+UkM1YwTIQY=
501+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.19.0.20230717114303-9b6e07d6384b/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
502502
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
503503
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
504504
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
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 account
5+
6+
import (
7+
"context"
8+
"reflect"
9+
10+
"github.com/scaleway/scaleway-cli/v2/internal/core"
11+
"github.com/scaleway/scaleway-sdk-go/api/account/v3"
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+
accountRoot(),
23+
accountProject(),
24+
accountProjectCreate(),
25+
accountProjectList(),
26+
accountProjectGet(),
27+
accountProjectDelete(),
28+
accountProjectUpdate(),
29+
)
30+
}
31+
func accountRoot() *core.Command {
32+
return &core.Command{
33+
Short: `This API allows you to manage projects`,
34+
Long: `This API allows you to manage projects.`,
35+
Namespace: "account",
36+
}
37+
}
38+
39+
func accountProject() *core.Command {
40+
return &core.Command{
41+
Short: `Project management commands`,
42+
Long: `Project management commands.`,
43+
Namespace: "account",
44+
Resource: "project",
45+
}
46+
}
47+
48+
func accountProjectCreate() *core.Command {
49+
return &core.Command{
50+
Short: `Create a new Project for an Organization`,
51+
Long: `Generate a new Project for an Organization, specifying its configuration including name and description.`,
52+
Namespace: "account",
53+
Resource: "project",
54+
Verb: "create",
55+
// Deprecated: false,
56+
ArgsType: reflect.TypeOf(account.ProjectAPICreateProjectRequest{}),
57+
ArgSpecs: core.ArgSpecs{
58+
{
59+
Name: "name",
60+
Short: `Name of the Project`,
61+
Required: false,
62+
Deprecated: false,
63+
Positional: false,
64+
Default: core.RandomValueGenerator("proj"),
65+
},
66+
{
67+
Name: "description",
68+
Short: `Description of the Project`,
69+
Required: false,
70+
Deprecated: false,
71+
Positional: false,
72+
},
73+
core.OrganizationIDArgSpec(),
74+
},
75+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
76+
request := args.(*account.ProjectAPICreateProjectRequest)
77+
78+
client := core.ExtractClient(ctx)
79+
api := account.NewProjectAPI(client)
80+
return api.CreateProject(request)
81+
82+
},
83+
}
84+
}
85+
86+
func accountProjectList() *core.Command {
87+
return &core.Command{
88+
Short: `List all Projects of an Organization`,
89+
Long: `List all Projects of an Organization. The response will include the total number of Projects as well as their associated Organizations, names, and IDs. Other information includes the creation and update date of the Project.`,
90+
Namespace: "account",
91+
Resource: "project",
92+
Verb: "list",
93+
// Deprecated: false,
94+
ArgsType: reflect.TypeOf(account.ProjectAPIListProjectsRequest{}),
95+
ArgSpecs: core.ArgSpecs{
96+
{
97+
Name: "name",
98+
Short: `Name of the Project`,
99+
Required: false,
100+
Deprecated: false,
101+
Positional: false,
102+
},
103+
{
104+
Name: "order-by",
105+
Short: `Sort order of the returned Projects`,
106+
Required: false,
107+
Deprecated: false,
108+
Positional: false,
109+
EnumValues: []string{"created_at_asc", "created_at_desc", "name_asc", "name_desc"},
110+
},
111+
{
112+
Name: "project-ids.{index}",
113+
Short: `Project IDs to filter for. The results will be limited to any Projects with an ID in this array`,
114+
Required: false,
115+
Deprecated: false,
116+
Positional: false,
117+
},
118+
core.OrganizationIDArgSpec(),
119+
},
120+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
121+
request := args.(*account.ProjectAPIListProjectsRequest)
122+
123+
client := core.ExtractClient(ctx)
124+
api := account.NewProjectAPI(client)
125+
opts := []scw.RequestOption{scw.WithAllPages()}
126+
resp, err := api.ListProjects(request, opts...)
127+
if err != nil {
128+
return nil, err
129+
}
130+
return resp.Projects, nil
131+
132+
},
133+
}
134+
}
135+
136+
func accountProjectGet() *core.Command {
137+
return &core.Command{
138+
Short: `Get an existing Project`,
139+
Long: `Retrieve information about an existing Project, specified by its Project ID. Its full details, including ID, name and description, are returned in the response object.`,
140+
Namespace: "account",
141+
Resource: "project",
142+
Verb: "get",
143+
// Deprecated: false,
144+
ArgsType: reflect.TypeOf(account.ProjectAPIGetProjectRequest{}),
145+
ArgSpecs: core.ArgSpecs{
146+
core.ProjectIDArgSpec(),
147+
},
148+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
149+
request := args.(*account.ProjectAPIGetProjectRequest)
150+
151+
client := core.ExtractClient(ctx)
152+
api := account.NewProjectAPI(client)
153+
return api.GetProject(request)
154+
155+
},
156+
}
157+
}
158+
159+
func accountProjectDelete() *core.Command {
160+
return &core.Command{
161+
Short: `Delete an existing Project`,
162+
Long: `Delete an existing Project, specified by its Project ID. The Project needs to be empty (meaning there are no resources left in it) to be deleted effectively. Note that deleting a Project is permanent, and cannot be undone.`,
163+
Namespace: "account",
164+
Resource: "project",
165+
Verb: "delete",
166+
// Deprecated: false,
167+
ArgsType: reflect.TypeOf(account.ProjectAPIDeleteProjectRequest{}),
168+
ArgSpecs: core.ArgSpecs{
169+
core.ProjectIDArgSpec(),
170+
},
171+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
172+
request := args.(*account.ProjectAPIDeleteProjectRequest)
173+
174+
client := core.ExtractClient(ctx)
175+
api := account.NewProjectAPI(client)
176+
e = api.DeleteProject(request)
177+
if e != nil {
178+
return nil, e
179+
}
180+
return &core.SuccessResult{
181+
Resource: "project",
182+
Verb: "delete",
183+
}, nil
184+
},
185+
}
186+
}
187+
188+
func accountProjectUpdate() *core.Command {
189+
return &core.Command{
190+
Short: `Update Project`,
191+
Long: `Update the parameters of an existing Project, specified by its Project ID. These parameters include the name and description.`,
192+
Namespace: "account",
193+
Resource: "project",
194+
Verb: "update",
195+
// Deprecated: false,
196+
ArgsType: reflect.TypeOf(account.ProjectAPIUpdateProjectRequest{}),
197+
ArgSpecs: core.ArgSpecs{
198+
core.ProjectIDArgSpec(),
199+
{
200+
Name: "name",
201+
Short: `Name of the Project`,
202+
Required: false,
203+
Deprecated: false,
204+
Positional: false,
205+
},
206+
{
207+
Name: "description",
208+
Short: `Description of the Project`,
209+
Required: false,
210+
Deprecated: false,
211+
Positional: false,
212+
},
213+
},
214+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
215+
request := args.(*account.ProjectAPIUpdateProjectRequest)
216+
217+
client := core.ExtractClient(ctx)
218+
api := account.NewProjectAPI(client)
219+
return api.UpdateProject(request)
220+
221+
},
222+
}
223+
}

0 commit comments

Comments
 (0)