From 496fa5751e72d45749152c471df4c07c60961394 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Wed, 14 Apr 2021 08:53:05 +0000 Subject: [PATCH 1/2] feat: update generated cli --- internal/namespaces/iot/v1/iot_cli.go | 125 +++++++++++ internal/namespaces/rdb/v1/rdb_cli.go | 288 ++++++++++++++++++++++++++ 2 files changed, 413 insertions(+) diff --git a/internal/namespaces/iot/v1/iot_cli.go b/internal/namespaces/iot/v1/iot_cli.go index 2dd14f4a60..afee397047 100644 --- a/internal/namespaces/iot/v1/iot_cli.go +++ b/internal/namespaces/iot/v1/iot_cli.go @@ -44,6 +44,7 @@ func GetGeneratedCommands() *core.Commands { iotDeviceGetMetrics(), iotRouteList(), iotRouteCreate(), + iotRouteUpdate(), iotRouteGet(), iotRouteDelete(), iotNetworkList(), @@ -1194,6 +1195,130 @@ func iotRouteCreate() *core.Command { } } +func iotRouteUpdate() *core.Command { + return &core.Command{ + Short: `Update a route`, + Long: `Update a route.`, + Namespace: "iot", + Resource: "route", + Verb: "update", + // Deprecated: false, + ArgsType: reflect.TypeOf(iot.UpdateRouteRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "route-id", + Short: `Route id`, + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "name", + Short: `Route name`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "topic", + Short: `Topic the route subscribes to. It must be a valid MQTT topic and up to 65535 characters`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "s3-config.bucket-region", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "s3-config.bucket-name", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "s3-config.object-prefix", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "s3-config.strategy", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"unknown", "per_topic", "per_message"}, + }, + { + Name: "db-config.host", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "db-config.port", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "db-config.dbname", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "db-config.username", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "db-config.password", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "db-config.query", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "rest-config.verb", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"unknown", "get", "post", "put", "patch", "delete"}, + }, + { + Name: "rest-config.uri", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "rest-config.headers.value.{key}", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*iot.UpdateRouteRequest) + + client := core.ExtractClient(ctx) + api := iot.NewAPI(client) + return api.UpdateRoute(request) + + }, + } +} + func iotRouteGet() *core.Command { return &core.Command{ Short: `Get a route`, diff --git a/internal/namespaces/rdb/v1/rdb_cli.go b/internal/namespaces/rdb/v1/rdb_cli.go index a81e200913..230225418e 100644 --- a/internal/namespaces/rdb/v1/rdb_cli.go +++ b/internal/namespaces/rdb/v1/rdb_cli.go @@ -29,6 +29,7 @@ func GetGeneratedCommands() *core.Commands { rdbDatabase(), rdbNodeType(), rdbLog(), + rdbSnapshot(), rdbEngineList(), rdbNodeTypeList(), rdbBackupList(), @@ -61,6 +62,12 @@ func GetGeneratedCommands() *core.Commands { rdbDatabaseDelete(), rdbPrivilegeList(), rdbPrivilegeSet(), + rdbSnapshotList(), + rdbSnapshotGet(), + rdbSnapshotCreate(), + rdbSnapshotUpdate(), + rdbSnapshotDelete(), + rdbSnapshotRestore(), ) } func rdbRoot() *core.Command { @@ -160,6 +167,16 @@ 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`, @@ -552,6 +569,14 @@ func rdbInstanceUpgrade() *core.Command { Deprecated: false, Positional: false, }, + { + Name: "volume-type", + Short: `Change your instance storage type`, + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"lssd", "bssd"}, + }, core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), }, Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { @@ -1637,3 +1662,266 @@ func rdbPrivilegeSet() *core.Command { }, } } + +func rdbSnapshotList() *core.Command { + return &core.Command{ + Short: `List instance snapshots`, + Long: `List instance snapshots.`, + Namespace: "rdb", + Resource: "snapshot", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(rdb.ListSnapshotsRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "name", + Short: `Name of the snapshot`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "order-by", + Short: `Criteria to use when ordering snapshot listing`, + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"created_at_asc", "created_at_desc", "name_asc", "name_desc", "expires_at_asc", "expires_at_desc"}, + }, + { + Name: "instance-id", + Short: `UUID of the instance`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "project-id", + Short: `Project ID the snapshots belongs to`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "organization-id", + Short: `Organization ID the snapshots belongs to`, + 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.ListSnapshotsRequest) + + client := core.ExtractClient(ctx) + api := rdb.NewAPI(client) + resp, err := api.ListSnapshots(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Snapshots, nil + + }, + } +} + +func rdbSnapshotGet() *core.Command { + return &core.Command{ + Short: `Get an instance snapshot`, + Long: `Get an instance snapshot.`, + Namespace: "rdb", + Resource: "snapshot", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(rdb.GetSnapshotRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "snapshot-id", + Short: `UUID of the snapshot`, + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*rdb.GetSnapshotRequest) + + client := core.ExtractClient(ctx) + api := rdb.NewAPI(client) + return api.GetSnapshot(request) + + }, + } +} + +func rdbSnapshotCreate() *core.Command { + return &core.Command{ + Short: `Create an instance snapshot`, + Long: `Create an instance snapshot.`, + Namespace: "rdb", + Resource: "snapshot", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(rdb.CreateSnapshotRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "instance-id", + Short: `UUID of the instance`, + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "name", + Short: `Name of the snapshot`, + Required: true, + Deprecated: false, + Positional: false, + Default: core.RandomValueGenerator("snp"), + }, + { + Name: "expires-at", + Short: `Expiration date (Format ISO 8601)`, + 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.CreateSnapshotRequest) + + client := core.ExtractClient(ctx) + api := rdb.NewAPI(client) + return api.CreateSnapshot(request) + + }, + } +} + +func rdbSnapshotUpdate() *core.Command { + return &core.Command{ + Short: `Update an instance snapshot`, + Long: `Update an instance snapshot.`, + Namespace: "rdb", + Resource: "snapshot", + Verb: "update", + // Deprecated: false, + ArgsType: reflect.TypeOf(rdb.UpdateSnapshotRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "snapshot-id", + Short: `UUID of the snapshot to update`, + Required: true, + Deprecated: false, + Positional: true, + }, + { + Name: "name", + Short: `Name of the snapshot`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "expires-at", + Short: `Expiration date (Format ISO 8601)`, + 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.UpdateSnapshotRequest) + + client := core.ExtractClient(ctx) + api := rdb.NewAPI(client) + return api.UpdateSnapshot(request) + + }, + } +} + +func rdbSnapshotDelete() *core.Command { + return &core.Command{ + Short: `Delete an instance snapshot`, + Long: `Delete an instance snapshot.`, + Namespace: "rdb", + Resource: "snapshot", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(rdb.DeleteSnapshotRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "snapshot-id", + Short: `UUID of the snapshot to delete`, + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*rdb.DeleteSnapshotRequest) + + client := core.ExtractClient(ctx) + api := rdb.NewAPI(client) + return api.DeleteSnapshot(request) + + }, + } +} + +func rdbSnapshotRestore() *core.Command { + return &core.Command{ + Short: `Create a new instance from a given snapshot`, + Long: `Create a new instance from a given snapshot.`, + Namespace: "rdb", + Resource: "snapshot", + Verb: "restore", + // Deprecated: false, + ArgsType: reflect.TypeOf(rdb.CreateInstanceFromSnapshotRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "snapshot-id", + Short: `Block snapshot of the instance`, + Required: true, + Deprecated: false, + Positional: true, + }, + { + Name: "instance-name", + Short: `Name of the instance created with the snapshot`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "is-ha-cluster", + Short: `Whether or not High-Availability is enabled on the new instance`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "node-type", + Short: `The node type used to restore the snapshot`, + 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.CreateInstanceFromSnapshotRequest) + + client := core.ExtractClient(ctx) + api := rdb.NewAPI(client) + return api.CreateInstanceFromSnapshot(request) + + }, + } +} From b7f87aac2706c106dd705576a3ee14bdfaa1aa26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Wed, 14 Apr 2021 11:19:34 +0200 Subject: [PATCH 2/2] Fix --- ...ll-usage-rdb-instance-upgrade-usage.golden | 1 + ...all-usage-rdb-snapshot-create-usage.golden | 21 ++++++++++++++++ ...all-usage-rdb-snapshot-delete-usage.golden | 19 ++++++++++++++ ...st-all-usage-rdb-snapshot-get-usage.golden | 19 ++++++++++++++ ...t-all-usage-rdb-snapshot-list-usage.golden | 23 +++++++++++++++++ ...ll-usage-rdb-snapshot-restore-usage.golden | 22 ++++++++++++++++ ...all-usage-rdb-snapshot-update-usage.golden | 21 ++++++++++++++++ .../test-all-usage-rdb-snapshot-usage.golden | 25 +++++++++++++++++++ .../testdata/test-all-usage-rdb-usage.golden | 1 + 9 files changed, 152 insertions(+) create mode 100644 cmd/scw/testdata/test-all-usage-rdb-snapshot-create-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-rdb-snapshot-delete-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-rdb-snapshot-get-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-rdb-snapshot-list-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-rdb-snapshot-restore-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-rdb-snapshot-update-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-rdb-snapshot-usage.golden diff --git a/cmd/scw/testdata/test-all-usage-rdb-instance-upgrade-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-instance-upgrade-usage.golden index b8b8450be3..07866ea7ae 100644 --- a/cmd/scw/testdata/test-all-usage-rdb-instance-upgrade-usage.golden +++ b/cmd/scw/testdata/test-all-usage-rdb-instance-upgrade-usage.golden @@ -10,6 +10,7 @@ ARGS: [node-type] Node type of the instance you want to upgrade to (DB-DEV-S | DB-DEV-M | DB-DEV-L | DB-DEV-XL | DB-GP-XS | DB-GP-S | DB-GP-M | DB-GP-L | DB-GP-XL) [enable-ha] Set to true to enable high availability on your instance [volume-size] Increase your block storage volume size + [volume-type] Change your instance storage type (lssd | bssd) [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw) FLAGS: diff --git a/cmd/scw/testdata/test-all-usage-rdb-snapshot-create-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-snapshot-create-usage.golden new file mode 100644 index 0000000000..f1575ef90a --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-rdb-snapshot-create-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Create an instance snapshot. + +USAGE: + scw rdb snapshot create [arg=value ...] + +ARGS: + instance-id UUID of the instance + name= Name of the snapshot + [expires-at] Expiration date (Format ISO 8601) + [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 + +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-snapshot-delete-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-snapshot-delete-usage.golden new file mode 100644 index 0000000000..892161a950 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-rdb-snapshot-delete-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Delete an instance snapshot. + +USAGE: + scw rdb snapshot delete [arg=value ...] + +ARGS: + snapshot-id UUID of the snapshot to delete + [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 + +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-snapshot-get-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-snapshot-get-usage.golden new file mode 100644 index 0000000000..f3deea1556 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-rdb-snapshot-get-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get an instance snapshot. + +USAGE: + scw rdb snapshot get [arg=value ...] + +ARGS: + snapshot-id UUID of the snapshot + [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 + +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-snapshot-list-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-snapshot-list-usage.golden new file mode 100644 index 0000000000..db13b6ba57 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-rdb-snapshot-list-usage.golden @@ -0,0 +1,23 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List instance snapshots. + +USAGE: + scw rdb snapshot list [arg=value ...] + +ARGS: + [name] Name of the snapshot + [order-by] Criteria to use when ordering snapshot listing (created_at_asc | created_at_desc | name_asc | name_desc | expires_at_asc | expires_at_desc) + [instance-id] UUID of the instance + [project-id] Project ID the snapshots belongs to + [organization-id] Organization ID the snapshots belongs to + [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 + +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-snapshot-restore-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-snapshot-restore-usage.golden new file mode 100644 index 0000000000..a1a95ab5c1 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-rdb-snapshot-restore-usage.golden @@ -0,0 +1,22 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Create a new instance from a given snapshot. + +USAGE: + scw rdb snapshot restore [arg=value ...] + +ARGS: + snapshot-id Block snapshot of the instance + [instance-name] Name of the instance created with the snapshot + [is-ha-cluster] Whether or not High-Availability is enabled on the new instance + [node-type] The node type used to restore the snapshot + [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 restore + +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-snapshot-update-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-snapshot-update-usage.golden new file mode 100644 index 0000000000..7532f69f96 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-rdb-snapshot-update-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Update an instance snapshot. + +USAGE: + scw rdb snapshot update [arg=value ...] + +ARGS: + snapshot-id UUID of the snapshot to update + [name] Name of the snapshot + [expires-at] Expiration date (Format ISO 8601) + [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 + +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-snapshot-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-snapshot-usage.golden new file mode 100644 index 0000000000..fbefc7d308 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-rdb-snapshot-usage.golden @@ -0,0 +1,25 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Create, restore and manage block snapshot + +USAGE: + scw rdb snapshot + +AVAILABLE COMMANDS: + create Create an instance snapshot + delete Delete an instance snapshot + get Get an instance snapshot + list List instance snapshots + restore Create a new instance from a given snapshot + update Update an instance 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 + +Use "scw rdb snapshot [command] --help" for more information about a command. 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: