Skip to content

feat(file): generate cli #4671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/mattn/go-isatty v0.0.20
github.com/moby/buildkit v0.13.2
github.com/opencontainers/go-digest v1.0.0
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250410154307-3c13436677ce
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250415141343-ed7d8fa2ef23
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250410154307-3c13436677ce h1:1kXeIBKCd3EwnLmysJlOWDjRN+0WAKsSipkDxZvOCW4=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250410154307-3c13436677ce/go.mod h1:w4o02EHpO0CBGy2nehzWRaFQKd62G9HIf+Q07PDaUcE=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250415141343-ed7d8fa2ef23 h1:ahwe042nQ9ZfsUnoMIAvzctygyQAAu7sdVXswFP2KT8=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250415141343-ed7d8fa2ef23/go.mod h1:w4o02EHpO0CBGy2nehzWRaFQKd62G9HIf+Q07PDaUcE=
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
github.com/secure-systems-lab/go-securesystemslib v0.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA=
Expand Down
361 changes: 361 additions & 0 deletions internal/namespaces/file/v1alpha1/file_cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,361 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.

package file

import (
"context"
"reflect"

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

// always import dependencies
var (
_ = scw.RegionFrPar
)

func GetGeneratedCommands() *core.Commands {
return core.NewCommands(
fileRoot(),
fileFilesystem(),
fileAttachment(),
fileFilesystemGet(),
fileFilesystemList(),
fileAttachmentList(),
fileFilesystemCreate(),
fileFilesystemDelete(),
fileFilesystemUpdate(),
)
}

func fileRoot() *core.Command {
return &core.Command{
Short: `This API allows you to manage your File Storage resources`,
Long: `This API allows you to manage your File Storage resources.`,
Namespace: "file",
}
}

func fileFilesystem() *core.Command {
return &core.Command{
Short: `Filesystem management`,
Long: `Filesystem management.`,
Namespace: "file",
Resource: "filesystem",
}
}

func fileAttachment() *core.Command {
return &core.Command{
Short: `Attachment management`,
Long: `Attachment management.`,
Namespace: "file",
Resource: "attachment",
}
}

func fileFilesystemGet() *core.Command {
return &core.Command{
Short: `Get filesystem details`,
Long: `Retrieve all properties and current status of a specific filesystem identified by its ID.`,
Namespace: "file",
Resource: "filesystem",
Verb: "get",
// Deprecated: false,
ArgsType: reflect.TypeOf(file.GetFileSystemRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "filesystem-id",
Short: `UUID of the filesystem`,
Required: true,
Deprecated: false,
Positional: true,
},
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*file.GetFileSystemRequest)

client := core.ExtractClient(ctx)
api := file.NewAPI(client)

return api.GetFileSystem(request)
},
}
}

func fileFilesystemList() *core.Command {
return &core.Command{
Short: `List all filesystems`,
Long: `Retrieve all filesystems in the specified region. Results are ordered by creation date in ascending order by default.
Use the order_by parameter to modify the sorting behavior.`,
Namespace: "file",
Resource: "filesystem",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(file.ListFileSystemsRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "order-by",
Short: `Criteria to use when ordering the list`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{
"created_at_asc",
"created_at_desc",
"name_asc",
"name_desc",
},
},
{
Name: "project-id",
Short: `Filter by project ID`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "name",
Short: `Filter the return filesystems by their names`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "tags.{index}",
Short: `Filter by tags. Only filesystems with one or more matching tags will be returned`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(
scw.RegionFrPar,
scw.Region(core.AllLocalities),
),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*file.ListFileSystemsRequest)

client := core.ExtractClient(ctx)
api := file.NewAPI(client)
opts := []scw.RequestOption{scw.WithAllPages()}
if request.Region == scw.Region(core.AllLocalities) {
opts = append(opts, scw.WithRegions(api.Regions()...))
request.Region = ""
}
resp, err := api.ListFileSystems(request, opts...)
if err != nil {
return nil, err
}

return resp.Filesystems, nil
},
}
}

func fileAttachmentList() *core.Command {
return &core.Command{
Short: `List filesystems attachments`,
Long: `List all existing attachments in a specified region.
By default, the attachments listed are ordered by creation date in ascending order.
This can be modified using the ` + "`" + `order_by` + "`" + ` field.`,
Namespace: "file",
Resource: "attachment",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(file.ListAttachmentsRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "filesystem-id",
Short: `UUID of the File Storage volume`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "resource-id",
Short: `Filter by resource ID`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "resource-type",
Short: `Filter by resource type`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{
"unknown_resource_type",
"instance_server",
},
},
{
Name: "zone",
Short: `Filter by resource zone`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(
scw.RegionFrPar,
scw.Region(core.AllLocalities),
),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*file.ListAttachmentsRequest)

client := core.ExtractClient(ctx)
api := file.NewAPI(client)
opts := []scw.RequestOption{scw.WithAllPages()}
if request.Region == scw.Region(core.AllLocalities) {
opts = append(opts, scw.WithRegions(api.Regions()...))
request.Region = ""
}
resp, err := api.ListAttachments(request, opts...)
if err != nil {
return nil, err
}

return resp.Attachments, nil
},
}
}

func fileFilesystemCreate() *core.Command {
return &core.Command{
Short: `Create a new filesystem`,
Long: `To create a new filesystem, you need to provide a name, a size, and a project ID.`,
Namespace: "file",
Resource: "filesystem",
Verb: "create",
// Deprecated: false,
ArgsType: reflect.TypeOf(file.CreateFileSystemRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "name",
Short: `Name of the filesystem`,
Required: true,
Deprecated: false,
Positional: false,
},
core.ProjectIDArgSpec(),
{
Name: "size",
Short: `Filesystem size in bytes, with a granularity of 100 GB (10^11 bytes).`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "tags.{index}",
Short: `List of tags assigned to the filesystem`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*file.CreateFileSystemRequest)

client := core.ExtractClient(ctx)
api := file.NewAPI(client)

return api.CreateFileSystem(request)
},
}
}

func fileFilesystemDelete() *core.Command {
return &core.Command{
Short: `Delete a detached filesystem`,
Long: `You must specify the ` + "`" + `filesystem_id` + "`" + ` of the filesystem you want to delete.`,
Namespace: "file",
Resource: "filesystem",
Verb: "delete",
// Deprecated: false,
ArgsType: reflect.TypeOf(file.DeleteFileSystemRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "filesystem-id",
Short: `UUID of the filesystem`,
Required: true,
Deprecated: false,
Positional: true,
},
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*file.DeleteFileSystemRequest)

client := core.ExtractClient(ctx)
api := file.NewAPI(client)
e = api.DeleteFileSystem(request)
if e != nil {
return nil, e
}

return &core.SuccessResult{
Resource: "filesystem",
Verb: "delete",
}, nil
},
}
}

func fileFilesystemUpdate() *core.Command {
return &core.Command{
Short: `Update filesystem properties`,
Long: `Update the technical details of a filesystem, such as its name, tags or its new size.
You can only resize a filesystem to a larger size.`,
Namespace: "file",
Resource: "filesystem",
Verb: "update",
// Deprecated: false,
ArgsType: reflect.TypeOf(file.UpdateFileSystemRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "filesystem-id",
Short: `UUID of the filesystem`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "name",
Short: `When defined, is the new name of the filesystem`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "size",
Short: `Optional field for increasing the size of the filesystem (must be larger than the current size)`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "tags.{index}",
Short: `List of tags assigned to the filesystem`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*file.UpdateFileSystemRequest)

client := core.ExtractClient(ctx)
api := file.NewAPI(client)

return api.UpdateFileSystem(request)
},
}
}
Loading