Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone committed Apr 7, 2021
1 parent 480922c commit 981e44d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 288 deletions.
19 changes: 19 additions & 0 deletions cmd/scw/testdata/test-all-usage-iot-hub-get-ca-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Get the certificate authority of a hub.

USAGE:
scw iot hub get-ca [arg=value ...]

ARGS:
hub-id
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)

FLAGS:
-h, --help help for get-ca

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
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-all-usage-iot-hub-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ AVAILABLE COMMANDS:
disable Disable a hub
enable Enable a hub
get Get a hub
get-ca Get the certificate authority of a hub
list List hubs
set-ca Set the certificate authority of a hub
update Update a hub
Expand Down
288 changes: 0 additions & 288 deletions internal/namespaces/rdb/v1/rdb_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func GetGeneratedCommands() *core.Commands {
rdbDatabase(),
rdbNodeType(),
rdbLog(),
rdbSnapshot(),
rdbEngineList(),
rdbNodeTypeList(),
rdbBackupList(),
Expand Down Expand Up @@ -62,12 +61,6 @@ func GetGeneratedCommands() *core.Commands {
rdbDatabaseDelete(),
rdbPrivilegeList(),
rdbPrivilegeSet(),
rdbSnapshotList(),
rdbSnapshotGet(),
rdbSnapshotCreate(),
rdbSnapshotUpdate(),
rdbSnapshotDelete(),
rdbSnapshotRestore(),
)
}
func rdbRoot() *core.Command {
Expand Down Expand Up @@ -167,16 +160,6 @@ 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`,
Expand Down Expand Up @@ -569,14 +552,6 @@ 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) {
Expand Down Expand Up @@ -1662,266 +1637,3 @@ 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)

},
}
}

0 comments on commit 981e44d

Please sign in to comment.