diff --git a/cmd/scw/testdata/test-all-usage-rdb-snapshot-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-snapshot-usage.golden new file mode 100644 index 0000000000..81a8689871 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-rdb-snapshot-usage.golden @@ -0,0 +1,15 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Create, restore and manage block snapshot + +USAGE: + scw rdb snapshot + +FLAGS: + -h, --help help for snapshot + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-rdb-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-usage.golden index 9719360f63..bbf10bae91 100644 --- a/cmd/scw/testdata/test-all-usage-rdb-usage.golden +++ b/cmd/scw/testdata/test-all-usage-rdb-usage.golden @@ -14,6 +14,7 @@ AVAILABLE COMMANDS: log Instance logs management commands node-type Node types management commands privilege User privileges management commands + snapshot Block snapshot management user User management commands FLAGS: diff --git a/cmd/scw/testdata/test-all-usage-registry-image-delete-usage.golden b/cmd/scw/testdata/test-all-usage-registry-image-delete-usage.golden index eaf7bde047..7f7ba574f9 100644 --- a/cmd/scw/testdata/test-all-usage-registry-image-delete-usage.golden +++ b/cmd/scw/testdata/test-all-usage-registry-image-delete-usage.golden @@ -7,7 +7,7 @@ USAGE: ARGS: image-id The unique ID of the Image - [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) FLAGS: -h, --help help for delete diff --git a/cmd/scw/testdata/test-all-usage-registry-image-get-usage.golden b/cmd/scw/testdata/test-all-usage-registry-image-get-usage.golden index 54207ac1e9..a622aadffc 100644 --- a/cmd/scw/testdata/test-all-usage-registry-image-get-usage.golden +++ b/cmd/scw/testdata/test-all-usage-registry-image-get-usage.golden @@ -7,7 +7,7 @@ USAGE: ARGS: image-id The unique ID of the Image - [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) FLAGS: -h, --help help for get diff --git a/cmd/scw/testdata/test-all-usage-registry-image-list-usage.golden b/cmd/scw/testdata/test-all-usage-registry-image-list-usage.golden index 58fc3fc4db..652e386b43 100644 --- a/cmd/scw/testdata/test-all-usage-registry-image-list-usage.golden +++ b/cmd/scw/testdata/test-all-usage-registry-image-list-usage.golden @@ -11,7 +11,7 @@ ARGS: [name] Filter by the Image name (exact match) [project-id] Filter by Project ID [organization-id] Filter by Organization ID - [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) FLAGS: -h, --help help for list diff --git a/cmd/scw/testdata/test-all-usage-registry-image-update-usage.golden b/cmd/scw/testdata/test-all-usage-registry-image-update-usage.golden index 6724821459..ed9744896c 100644 --- a/cmd/scw/testdata/test-all-usage-registry-image-update-usage.golden +++ b/cmd/scw/testdata/test-all-usage-registry-image-update-usage.golden @@ -8,7 +8,7 @@ USAGE: ARGS: image-id Image ID to update [visibility] A `public` image is pullable from internet without authentication, opposed to a `private` image. `inherit` will use the namespace `is_public` parameter (visibility_unknown | inherit | public | private) - [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) FLAGS: -h, --help help for update diff --git a/cmd/scw/testdata/test-all-usage-registry-namespace-create-usage.golden b/cmd/scw/testdata/test-all-usage-registry-namespace-create-usage.golden index 9cf8ad7761..f90a5c11eb 100644 --- a/cmd/scw/testdata/test-all-usage-registry-namespace-create-usage.golden +++ b/cmd/scw/testdata/test-all-usage-registry-namespace-create-usage.golden @@ -11,7 +11,7 @@ ARGS: [project-id] Project ID to use. If none is passed the default project ID will be used [is-public] Define the default visibility policy [organization-id] Organization ID to use. If none is passed the default organization ID will be used - [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) FLAGS: -h, --help help for create diff --git a/cmd/scw/testdata/test-all-usage-registry-namespace-delete-usage.golden b/cmd/scw/testdata/test-all-usage-registry-namespace-delete-usage.golden index d2de9672a7..58fabe4eb3 100644 --- a/cmd/scw/testdata/test-all-usage-registry-namespace-delete-usage.golden +++ b/cmd/scw/testdata/test-all-usage-registry-namespace-delete-usage.golden @@ -7,7 +7,7 @@ USAGE: ARGS: namespace-id The unique ID of the Namespace - [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) FLAGS: -h, --help help for delete diff --git a/cmd/scw/testdata/test-all-usage-registry-namespace-get-usage.golden b/cmd/scw/testdata/test-all-usage-registry-namespace-get-usage.golden index 555ba5d991..dbf7824180 100644 --- a/cmd/scw/testdata/test-all-usage-registry-namespace-get-usage.golden +++ b/cmd/scw/testdata/test-all-usage-registry-namespace-get-usage.golden @@ -7,7 +7,7 @@ USAGE: ARGS: namespace-id The unique ID of the Namespace - [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) FLAGS: -h, --help help for get diff --git a/cmd/scw/testdata/test-all-usage-registry-namespace-list-usage.golden b/cmd/scw/testdata/test-all-usage-registry-namespace-list-usage.golden index 5dcfc410fd..8a5fd86abe 100644 --- a/cmd/scw/testdata/test-all-usage-registry-namespace-list-usage.golden +++ b/cmd/scw/testdata/test-all-usage-registry-namespace-list-usage.golden @@ -10,7 +10,7 @@ ARGS: [project-id] Filter by Project ID [name] Filter by the namespace name (exact match) [organization-id] Filter by Organization ID - [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) FLAGS: -h, --help help for list diff --git a/cmd/scw/testdata/test-all-usage-registry-namespace-update-usage.golden b/cmd/scw/testdata/test-all-usage-registry-namespace-update-usage.golden index d819bf8e9a..b318102e40 100644 --- a/cmd/scw/testdata/test-all-usage-registry-namespace-update-usage.golden +++ b/cmd/scw/testdata/test-all-usage-registry-namespace-update-usage.golden @@ -9,7 +9,7 @@ ARGS: namespace-id Namespace ID to update [description] Define a description [is-public] Define the default visibility policy - [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) FLAGS: -h, --help help for update diff --git a/cmd/scw/testdata/test-all-usage-registry-tag-delete-usage.golden b/cmd/scw/testdata/test-all-usage-registry-tag-delete-usage.golden index 7133b214d8..4681d525ba 100644 --- a/cmd/scw/testdata/test-all-usage-registry-tag-delete-usage.golden +++ b/cmd/scw/testdata/test-all-usage-registry-tag-delete-usage.golden @@ -8,7 +8,7 @@ USAGE: ARGS: tag-id The unique ID of the tag [force] If two tags share the same digest the deletion will fail unless this parameter is set to true - [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) FLAGS: -h, --help help for delete diff --git a/cmd/scw/testdata/test-all-usage-registry-tag-get-usage.golden b/cmd/scw/testdata/test-all-usage-registry-tag-get-usage.golden index bb64f69e80..b62112f226 100644 --- a/cmd/scw/testdata/test-all-usage-registry-tag-get-usage.golden +++ b/cmd/scw/testdata/test-all-usage-registry-tag-get-usage.golden @@ -7,7 +7,7 @@ USAGE: ARGS: tag-id The unique ID of the Tag - [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) FLAGS: -h, --help help for get diff --git a/cmd/scw/testdata/test-all-usage-registry-tag-list-usage.golden b/cmd/scw/testdata/test-all-usage-registry-tag-list-usage.golden index 30fb64a862..c2e69da963 100644 --- a/cmd/scw/testdata/test-all-usage-registry-tag-list-usage.golden +++ b/cmd/scw/testdata/test-all-usage-registry-tag-list-usage.golden @@ -9,7 +9,7 @@ ARGS: [order-by] Field by which to order the display of Images (created_at_asc | created_at_desc | name_asc | name_desc) image-id The unique ID of the image [name] Filter by the tag name (exact match) - [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) FLAGS: -h, --help help for list diff --git a/internal/namespaces/rdb/v1/rdb_cli.go b/internal/namespaces/rdb/v1/rdb_cli.go index bed501247f..8d9addcd41 100644 --- a/internal/namespaces/rdb/v1/rdb_cli.go +++ b/internal/namespaces/rdb/v1/rdb_cli.go @@ -29,6 +29,9 @@ func GetGeneratedCommands() *core.Commands { rdbDatabase(), rdbNodeType(), rdbLog(), + rdbSnapshot(), + rdbEngineList(), + rdbNodeTypeList(), rdbBackupList(), rdbBackupCreate(), rdbBackupGet(), @@ -36,14 +39,13 @@ func GetGeneratedCommands() *core.Commands { rdbBackupDelete(), rdbBackupRestore(), rdbBackupExport(), - rdbInstanceClone(), - rdbEngineList(), rdbInstanceUpgrade(), rdbInstanceList(), rdbInstanceGet(), rdbInstanceCreate(), rdbInstanceUpdate(), rdbInstanceDelete(), + rdbInstanceClone(), rdbInstanceGetCertificate(), rdbLogPrepare(), rdbLogList(), @@ -60,7 +62,6 @@ func GetGeneratedCommands() *core.Commands { rdbDatabaseDelete(), rdbPrivilegeList(), rdbPrivilegeSet(), - rdbNodeTypeList(), ) } func rdbRoot() *core.Command { @@ -160,6 +161,77 @@ func rdbLog() *core.Command { } } +func rdbSnapshot() *core.Command { + return &core.Command{ + Short: `Block snapshot management`, + Long: `Create, restore and manage block snapshot +`, + Namespace: "rdb", + Resource: "snapshot", + } +} + +func rdbEngineList() *core.Command { + return &core.Command{ + Short: `List available database engines`, + Long: `List available database engines.`, + Namespace: "rdb", + Resource: "engine", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(rdb.ListDatabaseEnginesRequest{}), + ArgSpecs: core.ArgSpecs{ + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*rdb.ListDatabaseEnginesRequest) + + client := core.ExtractClient(ctx) + api := rdb.NewAPI(client) + resp, err := api.ListDatabaseEngines(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Engines, nil + + }, + } +} + +func rdbNodeTypeList() *core.Command { + return &core.Command{ + Short: `List available node types`, + Long: `List available node types.`, + Namespace: "rdb", + Resource: "node-type", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(rdb.ListNodeTypesRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "include-disabled-types", + Short: `Whether or not to include disabled types`, + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*rdb.ListNodeTypesRequest) + + client := core.ExtractClient(ctx) + api := rdb.NewAPI(client) + resp, err := api.ListNodeTypes(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.NodeTypes, nil + + }, + } +} + func rdbBackupList() *core.Command { return &core.Command{ Short: `List database backups`, @@ -453,77 +525,6 @@ func rdbBackupExport() *core.Command { } } -func rdbInstanceClone() *core.Command { - return &core.Command{ - Short: `Clone an instance`, - Long: `Clone an instance.`, - Namespace: "rdb", - Resource: "instance", - Verb: "clone", - // Deprecated: false, - ArgsType: reflect.TypeOf(rdb.CloneInstanceRequest{}), - ArgSpecs: core.ArgSpecs{ - { - Name: "instance-id", - Short: `UUID of the instance you want to clone`, - Required: true, - Deprecated: false, - Positional: true, - }, - { - Name: "name", - Short: `Name of the clone instance`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "node-type", - Short: `Node type of the clone`, - Required: false, - Deprecated: false, - Positional: false, - }, - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), - }, - Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { - request := args.(*rdb.CloneInstanceRequest) - - client := core.ExtractClient(ctx) - api := rdb.NewAPI(client) - return api.CloneInstance(request) - - }, - } -} - -func rdbEngineList() *core.Command { - return &core.Command{ - Short: `List available database engines`, - Long: `List available database engines.`, - Namespace: "rdb", - Resource: "engine", - Verb: "list", - // Deprecated: false, - ArgsType: reflect.TypeOf(rdb.ListDatabaseEnginesRequest{}), - ArgSpecs: core.ArgSpecs{ - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), - }, - Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { - request := args.(*rdb.ListDatabaseEnginesRequest) - - client := core.ExtractClient(ctx) - api := rdb.NewAPI(client) - resp, err := api.ListDatabaseEngines(request, scw.WithAllPages()) - if err != nil { - return nil, err - } - return resp.Engines, nil - - }, - } -} - func rdbInstanceUpgrade() *core.Command { return &core.Command{ Short: `Upgrade an instance to an higher instance type`, @@ -897,6 +898,50 @@ func rdbInstanceDelete() *core.Command { } } +func rdbInstanceClone() *core.Command { + return &core.Command{ + Short: `Clone an instance`, + Long: `Clone an instance.`, + Namespace: "rdb", + Resource: "instance", + Verb: "clone", + // Deprecated: false, + ArgsType: reflect.TypeOf(rdb.CloneInstanceRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "instance-id", + Short: `UUID of the instance you want to clone`, + Required: true, + Deprecated: false, + Positional: true, + }, + { + Name: "name", + Short: `Name of the clone instance`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "node-type", + Short: `Node type of the clone`, + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*rdb.CloneInstanceRequest) + + client := core.ExtractClient(ctx) + api := rdb.NewAPI(client) + return api.CloneInstance(request) + + }, + } +} + func rdbInstanceGetCertificate() *core.Command { return &core.Command{ Short: `Get the TLS certificate of an instance`, @@ -1596,37 +1641,3 @@ func rdbPrivilegeSet() *core.Command { }, } } - -func rdbNodeTypeList() *core.Command { - return &core.Command{ - Short: `List available node types`, - Long: `List available node types.`, - Namespace: "rdb", - Resource: "node-type", - Verb: "list", - // Deprecated: false, - ArgsType: reflect.TypeOf(rdb.ListNodeTypesRequest{}), - ArgSpecs: core.ArgSpecs{ - { - Name: "include-disabled-types", - Short: `Whether or not to include disabled types`, - Required: false, - Deprecated: false, - Positional: false, - }, - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), - }, - Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { - request := args.(*rdb.ListNodeTypesRequest) - - client := core.ExtractClient(ctx) - api := rdb.NewAPI(client) - resp, err := api.ListNodeTypes(request, scw.WithAllPages()) - if err != nil { - return nil, err - } - return resp.NodeTypes, nil - - }, - } -} diff --git a/internal/namespaces/registry/v1/registry_cli.go b/internal/namespaces/registry/v1/registry_cli.go index 66d74c69c5..30f6156b84 100644 --- a/internal/namespaces/registry/v1/registry_cli.go +++ b/internal/namespaces/registry/v1/registry_cli.go @@ -126,7 +126,7 @@ func registryNamespaceList() *core.Command { Deprecated: false, Positional: false, }, - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), }, Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { request := args.(*registry.ListNamespacesRequest) @@ -204,7 +204,7 @@ func registryNamespaceGet() *core.Command { Deprecated: false, Positional: true, }, - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), }, Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { request := args.(*registry.GetNamespaceRequest) @@ -250,7 +250,7 @@ func registryNamespaceCreate() *core.Command { Positional: false, }, core.OrganizationIDArgSpec(), - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), }, Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { request := args.(*registry.CreateNamespaceRequest) @@ -294,7 +294,7 @@ func registryNamespaceUpdate() *core.Command { Deprecated: false, Positional: false, }, - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), }, Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { request := args.(*registry.UpdateNamespaceRequest) @@ -324,7 +324,7 @@ func registryNamespaceDelete() *core.Command { Deprecated: false, Positional: true, }, - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), }, Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { request := args.(*registry.DeleteNamespaceRequest) @@ -383,7 +383,7 @@ func registryImageList() *core.Command { Deprecated: false, Positional: false, }, - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), }, Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { request := args.(*registry.ListImagesRequest) @@ -449,7 +449,7 @@ func registryImageGet() *core.Command { Deprecated: false, Positional: true, }, - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), }, Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { request := args.(*registry.GetImageRequest) @@ -487,7 +487,7 @@ func registryImageUpdate() *core.Command { Positional: false, EnumValues: []string{"visibility_unknown", "inherit", "public", "private"}, }, - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), }, Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { request := args.(*registry.UpdateImageRequest) @@ -517,7 +517,7 @@ func registryImageDelete() *core.Command { Deprecated: false, Positional: true, }, - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), }, Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { request := args.(*registry.DeleteImageRequest) @@ -562,7 +562,7 @@ func registryTagList() *core.Command { Deprecated: false, Positional: false, }, - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), }, Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { request := args.(*registry.ListTagsRequest) @@ -596,7 +596,7 @@ func registryTagGet() *core.Command { Deprecated: false, Positional: true, }, - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), }, Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { request := args.(*registry.GetTagRequest) @@ -633,7 +633,7 @@ func registryTagDelete() *core.Command { Deprecated: false, Positional: false, }, - core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), }, Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { request := args.(*registry.DeleteTagRequest)