diff --git a/commands/commands.go b/commands/commands.go index 7296db6db9..2257be3edd 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -20,6 +20,7 @@ import ( domain "github.com/scaleway/scaleway-cli/v2/internal/namespaces/domain/v2beta1" edgeservices "github.com/scaleway/scaleway-cli/v2/internal/namespaces/edge_services/v1beta1" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/feedback" + file "github.com/scaleway/scaleway-cli/v2/internal/namespaces/file/v1alpha1" flexibleip "github.com/scaleway/scaleway-cli/v2/internal/namespaces/flexibleip/v1alpha1" function "github.com/scaleway/scaleway-cli/v2/internal/namespaces/function/v1beta1" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/help" @@ -115,7 +116,10 @@ func GetCommands() *core.Commands { ) if beta { - commands.Merge(dedibox.GetCommands()) + commands.MergeAll( + dedibox.GetCommands(), + file.GetCommands(), + ) } return commands diff --git a/core/command.go b/core/command.go index dcfa18e9d8..786e01be0d 100644 --- a/core/command.go +++ b/core/command.go @@ -291,6 +291,12 @@ func (c *Commands) Merge(cmds *Commands) { } } +func (c *Commands) MergeAll(cmds ...*Commands) { + for _, command := range cmds { + c.Merge(command) + } +} + func (c *Commands) GetAll() []*Command { return c.commands } diff --git a/docs/commands/file.md b/docs/commands/file.md new file mode 100644 index 0000000000..714a193e09 --- /dev/null +++ b/docs/commands/file.md @@ -0,0 +1,160 @@ + +# Documentation for `scw file` +This API allows you to manage your File Storage resources. + +- [Attachment management](#attachment-management) + - [List filesystems attachments](#list-filesystems-attachments) +- [Filesystem management](#filesystem-management) + - [Create a new filesystem](#create-a-new-filesystem) + - [Delete a detached filesystem](#delete-a-detached-filesystem) + - [Get filesystem details](#get-filesystem-details) + - [List all filesystems](#list-all-filesystems) + - [Update filesystem properties](#update-filesystem-properties) + + +## Attachment management + +Attachment management. + + +### List filesystems attachments + +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. + +**Usage:** + +``` +scw file attachment list [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| filesystem-id | | UUID of the File Storage volume | +| resource-id | | Filter by resource ID | +| resource-type | One of: `unknown_resource_type`, `instance_server` | Filter by resource type | +| zone | | Filter by resource zone | +| region | Default: `fr-par`
One of: `fr-par`, `all` | Region to target. If none is passed will use default region from the config | + + + +## Filesystem management + +Filesystem management. + + +### Create a new filesystem + +To create a new filesystem, you need to provide a name, a size, and a project ID. + +**Usage:** + +``` +scw file filesystem create [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| name | Required | Name of the filesystem | +| project-id | | Project ID to use. If none is passed the default project ID will be used | +| size | Required | Filesystem size in bytes, with a granularity of 100 GB (10^11 bytes). | +| tags.{index} | | List of tags assigned to the filesystem | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + +### Delete a detached filesystem + +You must specify the `filesystem_id` of the filesystem you want to delete. + +**Usage:** + +``` +scw file filesystem delete [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| filesystem-id | Required | UUID of the filesystem | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + +### Get filesystem details + +Retrieve all properties and current status of a specific filesystem identified by its ID. + +**Usage:** + +``` +scw file filesystem get [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| filesystem-id | Required | UUID of the filesystem | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + +### List all filesystems + +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. + +**Usage:** + +``` +scw file filesystem list [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| order-by | One of: `created_at_asc`, `created_at_desc`, `name_asc`, `name_desc` | Criteria to use when ordering the list | +| project-id | | Filter by project ID | +| name | | Filter the return filesystems by their names | +| tags.{index} | | Filter by tags. Only filesystems with one or more matching tags will be returned | +| region | Default: `fr-par`
One of: `fr-par`, `all` | Region to target. If none is passed will use default region from the config | + + + +### Update filesystem properties + +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. + +**Usage:** + +``` +scw file filesystem update [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| filesystem-id | Required | UUID of the filesystem | +| name | | When defined, is the new name of the filesystem | +| size | | Optional field for increasing the size of the filesystem (must be larger than the current size) | +| tags.{index} | | List of tags assigned to the filesystem | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + diff --git a/internal/namespaces/file/v1alpha1/custom.go b/internal/namespaces/file/v1alpha1/custom.go new file mode 100644 index 0000000000..5c8af81e5f --- /dev/null +++ b/internal/namespaces/file/v1alpha1/custom.go @@ -0,0 +1,11 @@ +package file + +import "github.com/scaleway/scaleway-cli/v2/core" + +func GetCommands() *core.Commands { + cmds := GetGeneratedCommands() + + cmds.MustFind("file").Groups = []string{"storage"} + + return cmds +}