Skip to content

Commit 7e821bb

Browse files
scaleway-botjremy42
authored andcommitted
feat(file): generate cli (scaleway#4671)
Co-authored-by: devtools-ci-cd <[email protected]>
1 parent 439a3d9 commit 7e821bb

File tree

3 files changed

+364
-3
lines changed

3 files changed

+364
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
github.com/mattn/go-isatty v0.0.20
2424
github.com/moby/buildkit v0.13.2
2525
github.com/opencontainers/go-digest v1.0.0
26-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250410154307-3c13436677ce
26+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250415141343-ed7d8fa2ef23
2727
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
2828
github.com/spf13/cobra v1.9.1
2929
github.com/spf13/pflag v1.0.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
462462
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
463463
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
464464
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
465-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250410154307-3c13436677ce h1:1kXeIBKCd3EwnLmysJlOWDjRN+0WAKsSipkDxZvOCW4=
466-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250410154307-3c13436677ce/go.mod h1:w4o02EHpO0CBGy2nehzWRaFQKd62G9HIf+Q07PDaUcE=
465+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250415141343-ed7d8fa2ef23 h1:ahwe042nQ9ZfsUnoMIAvzctygyQAAu7sdVXswFP2KT8=
466+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250415141343-ed7d8fa2ef23/go.mod h1:w4o02EHpO0CBGy2nehzWRaFQKd62G9HIf+Q07PDaUcE=
467467
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
468468
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
469469
github.com/secure-systems-lab/go-securesystemslib v0.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA=
Lines changed: 361 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,361 @@
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 file
5+
6+
import (
7+
"context"
8+
"reflect"
9+
10+
"github.com/scaleway/scaleway-cli/v2/core"
11+
file "github.com/scaleway/scaleway-sdk-go/api/file/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+
fileRoot(),
23+
fileFilesystem(),
24+
fileAttachment(),
25+
fileFilesystemGet(),
26+
fileFilesystemList(),
27+
fileAttachmentList(),
28+
fileFilesystemCreate(),
29+
fileFilesystemDelete(),
30+
fileFilesystemUpdate(),
31+
)
32+
}
33+
34+
func fileRoot() *core.Command {
35+
return &core.Command{
36+
Short: `This API allows you to manage your File Storage resources`,
37+
Long: `This API allows you to manage your File Storage resources.`,
38+
Namespace: "file",
39+
}
40+
}
41+
42+
func fileFilesystem() *core.Command {
43+
return &core.Command{
44+
Short: `Filesystem management`,
45+
Long: `Filesystem management.`,
46+
Namespace: "file",
47+
Resource: "filesystem",
48+
}
49+
}
50+
51+
func fileAttachment() *core.Command {
52+
return &core.Command{
53+
Short: `Attachment management`,
54+
Long: `Attachment management.`,
55+
Namespace: "file",
56+
Resource: "attachment",
57+
}
58+
}
59+
60+
func fileFilesystemGet() *core.Command {
61+
return &core.Command{
62+
Short: `Get filesystem details`,
63+
Long: `Retrieve all properties and current status of a specific filesystem identified by its ID.`,
64+
Namespace: "file",
65+
Resource: "filesystem",
66+
Verb: "get",
67+
// Deprecated: false,
68+
ArgsType: reflect.TypeOf(file.GetFileSystemRequest{}),
69+
ArgSpecs: core.ArgSpecs{
70+
{
71+
Name: "filesystem-id",
72+
Short: `UUID of the filesystem`,
73+
Required: true,
74+
Deprecated: false,
75+
Positional: true,
76+
},
77+
core.RegionArgSpec(scw.RegionFrPar),
78+
},
79+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
80+
request := args.(*file.GetFileSystemRequest)
81+
82+
client := core.ExtractClient(ctx)
83+
api := file.NewAPI(client)
84+
85+
return api.GetFileSystem(request)
86+
},
87+
}
88+
}
89+
90+
func fileFilesystemList() *core.Command {
91+
return &core.Command{
92+
Short: `List all filesystems`,
93+
Long: `Retrieve all filesystems in the specified region. Results are ordered by creation date in ascending order by default.
94+
Use the order_by parameter to modify the sorting behavior.`,
95+
Namespace: "file",
96+
Resource: "filesystem",
97+
Verb: "list",
98+
// Deprecated: false,
99+
ArgsType: reflect.TypeOf(file.ListFileSystemsRequest{}),
100+
ArgSpecs: core.ArgSpecs{
101+
{
102+
Name: "order-by",
103+
Short: `Criteria to use when ordering the list`,
104+
Required: false,
105+
Deprecated: false,
106+
Positional: false,
107+
EnumValues: []string{
108+
"created_at_asc",
109+
"created_at_desc",
110+
"name_asc",
111+
"name_desc",
112+
},
113+
},
114+
{
115+
Name: "project-id",
116+
Short: `Filter by project ID`,
117+
Required: false,
118+
Deprecated: false,
119+
Positional: false,
120+
},
121+
{
122+
Name: "name",
123+
Short: `Filter the return filesystems by their names`,
124+
Required: false,
125+
Deprecated: false,
126+
Positional: false,
127+
},
128+
{
129+
Name: "tags.{index}",
130+
Short: `Filter by tags. Only filesystems with one or more matching tags will be returned`,
131+
Required: false,
132+
Deprecated: false,
133+
Positional: false,
134+
},
135+
core.RegionArgSpec(
136+
scw.RegionFrPar,
137+
scw.Region(core.AllLocalities),
138+
),
139+
},
140+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
141+
request := args.(*file.ListFileSystemsRequest)
142+
143+
client := core.ExtractClient(ctx)
144+
api := file.NewAPI(client)
145+
opts := []scw.RequestOption{scw.WithAllPages()}
146+
if request.Region == scw.Region(core.AllLocalities) {
147+
opts = append(opts, scw.WithRegions(api.Regions()...))
148+
request.Region = ""
149+
}
150+
resp, err := api.ListFileSystems(request, opts...)
151+
if err != nil {
152+
return nil, err
153+
}
154+
155+
return resp.Filesystems, nil
156+
},
157+
}
158+
}
159+
160+
func fileAttachmentList() *core.Command {
161+
return &core.Command{
162+
Short: `List filesystems attachments`,
163+
Long: `List all existing attachments in a specified region.
164+
By default, the attachments listed are ordered by creation date in ascending order.
165+
This can be modified using the ` + "`" + `order_by` + "`" + ` field.`,
166+
Namespace: "file",
167+
Resource: "attachment",
168+
Verb: "list",
169+
// Deprecated: false,
170+
ArgsType: reflect.TypeOf(file.ListAttachmentsRequest{}),
171+
ArgSpecs: core.ArgSpecs{
172+
{
173+
Name: "filesystem-id",
174+
Short: `UUID of the File Storage volume`,
175+
Required: false,
176+
Deprecated: false,
177+
Positional: false,
178+
},
179+
{
180+
Name: "resource-id",
181+
Short: `Filter by resource ID`,
182+
Required: false,
183+
Deprecated: false,
184+
Positional: false,
185+
},
186+
{
187+
Name: "resource-type",
188+
Short: `Filter by resource type`,
189+
Required: false,
190+
Deprecated: false,
191+
Positional: false,
192+
EnumValues: []string{
193+
"unknown_resource_type",
194+
"instance_server",
195+
},
196+
},
197+
{
198+
Name: "zone",
199+
Short: `Filter by resource zone`,
200+
Required: false,
201+
Deprecated: false,
202+
Positional: false,
203+
},
204+
core.RegionArgSpec(
205+
scw.RegionFrPar,
206+
scw.Region(core.AllLocalities),
207+
),
208+
},
209+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
210+
request := args.(*file.ListAttachmentsRequest)
211+
212+
client := core.ExtractClient(ctx)
213+
api := file.NewAPI(client)
214+
opts := []scw.RequestOption{scw.WithAllPages()}
215+
if request.Region == scw.Region(core.AllLocalities) {
216+
opts = append(opts, scw.WithRegions(api.Regions()...))
217+
request.Region = ""
218+
}
219+
resp, err := api.ListAttachments(request, opts...)
220+
if err != nil {
221+
return nil, err
222+
}
223+
224+
return resp.Attachments, nil
225+
},
226+
}
227+
}
228+
229+
func fileFilesystemCreate() *core.Command {
230+
return &core.Command{
231+
Short: `Create a new filesystem`,
232+
Long: `To create a new filesystem, you need to provide a name, a size, and a project ID.`,
233+
Namespace: "file",
234+
Resource: "filesystem",
235+
Verb: "create",
236+
// Deprecated: false,
237+
ArgsType: reflect.TypeOf(file.CreateFileSystemRequest{}),
238+
ArgSpecs: core.ArgSpecs{
239+
{
240+
Name: "name",
241+
Short: `Name of the filesystem`,
242+
Required: true,
243+
Deprecated: false,
244+
Positional: false,
245+
},
246+
core.ProjectIDArgSpec(),
247+
{
248+
Name: "size",
249+
Short: `Filesystem size in bytes, with a granularity of 100 GB (10^11 bytes).`,
250+
Required: true,
251+
Deprecated: false,
252+
Positional: false,
253+
},
254+
{
255+
Name: "tags.{index}",
256+
Short: `List of tags assigned to the filesystem`,
257+
Required: false,
258+
Deprecated: false,
259+
Positional: false,
260+
},
261+
core.RegionArgSpec(scw.RegionFrPar),
262+
},
263+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
264+
request := args.(*file.CreateFileSystemRequest)
265+
266+
client := core.ExtractClient(ctx)
267+
api := file.NewAPI(client)
268+
269+
return api.CreateFileSystem(request)
270+
},
271+
}
272+
}
273+
274+
func fileFilesystemDelete() *core.Command {
275+
return &core.Command{
276+
Short: `Delete a detached filesystem`,
277+
Long: `You must specify the ` + "`" + `filesystem_id` + "`" + ` of the filesystem you want to delete.`,
278+
Namespace: "file",
279+
Resource: "filesystem",
280+
Verb: "delete",
281+
// Deprecated: false,
282+
ArgsType: reflect.TypeOf(file.DeleteFileSystemRequest{}),
283+
ArgSpecs: core.ArgSpecs{
284+
{
285+
Name: "filesystem-id",
286+
Short: `UUID of the filesystem`,
287+
Required: true,
288+
Deprecated: false,
289+
Positional: true,
290+
},
291+
core.RegionArgSpec(scw.RegionFrPar),
292+
},
293+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
294+
request := args.(*file.DeleteFileSystemRequest)
295+
296+
client := core.ExtractClient(ctx)
297+
api := file.NewAPI(client)
298+
e = api.DeleteFileSystem(request)
299+
if e != nil {
300+
return nil, e
301+
}
302+
303+
return &core.SuccessResult{
304+
Resource: "filesystem",
305+
Verb: "delete",
306+
}, nil
307+
},
308+
}
309+
}
310+
311+
func fileFilesystemUpdate() *core.Command {
312+
return &core.Command{
313+
Short: `Update filesystem properties`,
314+
Long: `Update the technical details of a filesystem, such as its name, tags or its new size.
315+
You can only resize a filesystem to a larger size.`,
316+
Namespace: "file",
317+
Resource: "filesystem",
318+
Verb: "update",
319+
// Deprecated: false,
320+
ArgsType: reflect.TypeOf(file.UpdateFileSystemRequest{}),
321+
ArgSpecs: core.ArgSpecs{
322+
{
323+
Name: "filesystem-id",
324+
Short: `UUID of the filesystem`,
325+
Required: true,
326+
Deprecated: false,
327+
Positional: false,
328+
},
329+
{
330+
Name: "name",
331+
Short: `When defined, is the new name of the filesystem`,
332+
Required: false,
333+
Deprecated: false,
334+
Positional: false,
335+
},
336+
{
337+
Name: "size",
338+
Short: `Optional field for increasing the size of the filesystem (must be larger than the current size)`,
339+
Required: false,
340+
Deprecated: false,
341+
Positional: false,
342+
},
343+
{
344+
Name: "tags.{index}",
345+
Short: `List of tags assigned to the filesystem`,
346+
Required: false,
347+
Deprecated: false,
348+
Positional: false,
349+
},
350+
core.RegionArgSpec(scw.RegionFrPar),
351+
},
352+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
353+
request := args.(*file.UpdateFileSystemRequest)
354+
355+
client := core.ExtractClient(ctx)
356+
api := file.NewAPI(client)
357+
358+
return api.UpdateFileSystem(request)
359+
},
360+
}
361+
}

0 commit comments

Comments
 (0)