-
Notifications
You must be signed in to change notification settings - Fork 151
/
account_cli.go
228 lines (208 loc) · 6.35 KB
/
account_cli.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
package account
import (
"context"
"reflect"
"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-sdk-go/api/account/v2"
"github.com/scaleway/scaleway-sdk-go/scw"
)
// always import dependencies
var (
_ = scw.RegionFrPar
)
func GetGeneratedCommands() *core.Commands {
return core.NewCommands(
accountRoot(),
accountProject(),
accountProjectCreate(),
accountProjectList(),
accountProjectGet(),
accountProjectDelete(),
accountProjectUpdate(),
)
}
func accountRoot() *core.Command {
return &core.Command{
Short: `User related data`,
Long: `This API allows you to manage projects.`,
Namespace: "account",
}
}
func accountProject() *core.Command {
return &core.Command{
Short: `Project management commands`,
Long: `Project management commands.`,
Namespace: "account",
Resource: "project",
}
}
func accountProjectCreate() *core.Command {
return &core.Command{
Short: `Create a new Project for an Organization`,
Long: `Deprecated in favor of Account API v3.
Generate a new Project for an Organization, specifying its configuration including name and description.`,
Namespace: "account",
Resource: "project",
Verb: "create",
// Deprecated: true,
ArgsType: reflect.TypeOf(account.CreateProjectRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "name",
Short: `Name of the Project`,
Required: false,
Deprecated: false,
Positional: false,
Default: core.RandomValueGenerator("proj"),
},
{
Name: "description",
Short: `Description of the Project`,
Required: false,
Deprecated: false,
Positional: false,
},
core.OrganizationIDArgSpec(),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*account.CreateProjectRequest)
client := core.ExtractClient(ctx)
api := account.NewAPI(client)
return api.CreateProject(request)
},
}
}
func accountProjectList() *core.Command {
return &core.Command{
Short: `List all Projects of an Organization`,
Long: `Deprecated in favor of Account API v3.
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 include the creation and update date of the Project.`,
Namespace: "account",
Resource: "project",
Verb: "list",
// Deprecated: true,
ArgsType: reflect.TypeOf(account.ListProjectsRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "name",
Short: `Name of the Project`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "order-by",
Short: `Sort order of the returned Projects`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"created_at_asc", "created_at_desc", "name_asc", "name_desc"},
},
{
Name: "project-ids.{index}",
Short: `Project IDs to filter for. The results will be limited to any Projects with an ID in this array`,
Required: false,
Deprecated: false,
Positional: false,
},
core.OrganizationIDArgSpec(),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*account.ListProjectsRequest)
client := core.ExtractClient(ctx)
api := account.NewAPI(client)
opts := []scw.RequestOption{scw.WithAllPages()}
resp, err := api.ListProjects(request, opts...)
if err != nil {
return nil, err
}
return resp.Projects, nil
},
}
}
func accountProjectGet() *core.Command {
return &core.Command{
Short: `Get an existing Project`,
Long: `Deprecated in favor of Account API v3.
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.`,
Namespace: "account",
Resource: "project",
Verb: "get",
// Deprecated: true,
ArgsType: reflect.TypeOf(account.GetProjectRequest{}),
ArgSpecs: core.ArgSpecs{
core.ProjectIDArgSpec(),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*account.GetProjectRequest)
client := core.ExtractClient(ctx)
api := account.NewAPI(client)
return api.GetProject(request)
},
}
}
func accountProjectDelete() *core.Command {
return &core.Command{
Short: `Delete an existing Project`,
Long: `Deprecated in favor of Account API v3.
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.`,
Namespace: "account",
Resource: "project",
Verb: "delete",
// Deprecated: true,
ArgsType: reflect.TypeOf(account.DeleteProjectRequest{}),
ArgSpecs: core.ArgSpecs{
core.ProjectIDArgSpec(),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*account.DeleteProjectRequest)
client := core.ExtractClient(ctx)
api := account.NewAPI(client)
e = api.DeleteProject(request)
if e != nil {
return nil, e
}
return &core.SuccessResult{
Resource: "project",
Verb: "delete",
}, nil
},
}
}
func accountProjectUpdate() *core.Command {
return &core.Command{
Short: `Update Project`,
Long: `Deprecated in favor of Account API v3.
Update the parameters of an existing Project, specified by its Project ID. These parameters include the name and description.`,
Namespace: "account",
Resource: "project",
Verb: "update",
// Deprecated: true,
ArgsType: reflect.TypeOf(account.UpdateProjectRequest{}),
ArgSpecs: core.ArgSpecs{
core.ProjectIDArgSpec(),
{
Name: "name",
Short: `Name of the Project`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "description",
Short: `Description of the Project`,
Required: false,
Deprecated: false,
Positional: false,
},
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*account.UpdateProjectRequest)
client := core.ExtractClient(ctx)
api := account.NewAPI(client)
return api.UpdateProject(request)
},
}
}