Skip to content
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

feat(rdb): minor API doc spelling changes. #1627

Merged
merged 3 commits into from
Jan 4, 2021
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
List privileges of a given user in a given database in a given instance.
List privileges of a given user for a given database on a given instance.

USAGE:
scw rdb privilege list [arg=value ...]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Set privileges of a given user in a given database in a given instance.
Set privileges of a given user for a given database on a given instance.

USAGE:
scw rdb privilege set [arg=value ...]
Expand Down
4 changes: 2 additions & 2 deletions cmd/scw/testdata/test-all-usage-rdb-privilege-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ USAGE:
scw rdb privilege <command>

AVAILABLE COMMANDS:
list List privileges of a given user in a given database in a given instance
set Set privileges of a given user in a given database in a given instance
list List privileges of a given user for a given database on a given instance
set Set privileges of a given user for a given database on a given instance

FLAGS:
-h, --help help for privilege
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Create an user in a given instance.
Create a user on a given instance.

USAGE:
scw rdb user create [arg=value ...]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Delete an user in a given instance.
Delete a user on a given instance.

USAGE:
scw rdb user delete [arg=value ...]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Update an user in a given instance.
Update a user on a given instance.

USAGE:
scw rdb user update [arg=value ...]
Expand Down
6 changes: 3 additions & 3 deletions cmd/scw/testdata/test-all-usage-rdb-user-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ USAGE:
scw rdb user <command>

AVAILABLE COMMANDS:
create Create an user in a given instance
delete Delete an user in a given instance
create Create a user on a given instance
delete Delete a user on a given instance
list List users of a given instance
update Update an user in a given instance
update Update a user on a given instance

FLAGS:
-h, --help help for user
Expand Down
236 changes: 118 additions & 118 deletions internal/namespaces/rdb/v1/rdb_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,22 @@ func GetGeneratedCommands() *core.Commands {
rdbDatabase(),
rdbNodeType(),
rdbLog(),
rdbEngineList(),
rdbNodeTypeList(),
rdbBackupList(),
rdbBackupCreate(),
rdbBackupGet(),
rdbBackupUpdate(),
rdbBackupDelete(),
rdbBackupRestore(),
rdbBackupExport(),
rdbInstanceClone(),
rdbEngineList(),
rdbInstanceUpgrade(),
rdbInstanceList(),
rdbInstanceGet(),
rdbInstanceCreate(),
rdbInstanceUpdate(),
rdbInstanceDelete(),
rdbInstanceClone(),
rdbInstanceGetCertificate(),
rdbLogPrepare(),
rdbLogList(),
Expand All @@ -60,7 +61,6 @@ func GetGeneratedCommands() *core.Commands {
rdbDatabaseDelete(),
rdbPrivilegeList(),
rdbPrivilegeSet(),
rdbNodeTypeList(),
)
}
func rdbRoot() *core.Command {
Expand Down Expand Up @@ -160,6 +160,67 @@ func rdbLog() *core.Command {
}
}

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`,
Expand Down Expand Up @@ -453,77 +514,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`,
Expand Down Expand Up @@ -897,6 +887,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`,
Expand Down Expand Up @@ -1203,8 +1237,8 @@ func rdbUserList() *core.Command {

func rdbUserCreate() *core.Command {
return &core.Command{
Short: `Create an user in a given instance`,
Long: `Create an user in a given instance.`,
Short: `Create a user on a given instance`,
Long: `Create a user on a given instance.`,
Namespace: "rdb",
Resource: "user",
Verb: "create",
Expand Down Expand Up @@ -1254,8 +1288,8 @@ func rdbUserCreate() *core.Command {

func rdbUserUpdate() *core.Command {
return &core.Command{
Short: `Update an user in a given instance`,
Long: `Update an user in a given instance.`,
Short: `Update a user on a given instance`,
Long: `Update a user on a given instance.`,
Namespace: "rdb",
Resource: "user",
Verb: "update",
Expand Down Expand Up @@ -1305,8 +1339,8 @@ func rdbUserUpdate() *core.Command {

func rdbUserDelete() *core.Command {
return &core.Command{
Short: `Delete an user in a given instance`,
Long: `Delete an user in a given instance.`,
Short: `Delete a user on a given instance`,
Long: `Delete a user on a given instance.`,
Namespace: "rdb",
Resource: "user",
Verb: "delete",
Expand Down Expand Up @@ -1491,8 +1525,8 @@ func rdbDatabaseDelete() *core.Command {

func rdbPrivilegeList() *core.Command {
return &core.Command{
Short: `List privileges of a given user in a given database in a given instance`,
Long: `List privileges of a given user in a given database in a given instance.`,
Short: `List privileges of a given user for a given database on a given instance`,
Long: `List privileges of a given user for a given database on a given instance.`,
Namespace: "rdb",
Resource: "privilege",
Verb: "list",
Expand Down Expand Up @@ -1547,8 +1581,8 @@ func rdbPrivilegeList() *core.Command {

func rdbPrivilegeSet() *core.Command {
return &core.Command{
Short: `Set privileges of a given user in a given database in a given instance`,
Long: `Set privileges of a given user in a given database in a given instance.`,
Short: `Set privileges of a given user for a given database on a given instance`,
Long: `Set privileges of a given user for a given database on a given instance.`,
Namespace: "rdb",
Resource: "privilege",
Verb: "set",
Expand Down Expand Up @@ -1596,37 +1630,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

},
}
}