Skip to content
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
@@ -0,0 +1,20 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Create a new endpoint for a MongoDB® Database Instance. You can add `public_network` or `private_network` specifications to the body of the request.

USAGE:
scw mongodb endpoint create <instance-id ...> [arg=value ...]

ARGS:
instance-id UUID of the Database Instance
[endpoint.private-network.private-network-id] UUID of the Private Network
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Delete the endpoint of a Database Instance. You must specify the `endpoint_id` parameter of the endpoint you want to delete. Note that you might need to update any environment configurations that point to the deleted endpoint.

USAGE:
scw mongodb endpoint delete <endpoint-id ...> [arg=value ...]

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

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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
Instance endpoints enable connection to your instance.

USAGE:
scw mongodb endpoint
scw mongodb endpoint <command>

AVAILABLE COMMANDS:
create Create a new Instance endpoint
delete Delete a Database Instance endpoint

FLAGS:
-h, --help help for endpoint
Expand All @@ -13,3 +17,5 @@ GLOBAL FLAGS:
-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 mongodb endpoint [command] --help" for more information about a command.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Create an user on a Database Instance. You must define the `name`, `password` of the user and `instance_id` parameters in the request.

USAGE:
scw mongodb user create [arg=value ...]

ARGS:
instance-id UUID of the Database Instance the user belongs to
[name] Name of the database user
[password] Password of the database user
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)

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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ USAGE:
scw mongodb user <command>

AVAILABLE COMMANDS:
create Create an user on a Database Instance
delete Delete a user on a Database Instance
list List users of a Database Instance
set-role Apply user roles
Expand Down
61 changes: 59 additions & 2 deletions docs/commands/mongodb.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
This API allows you to manage your Managed Databases for MongoDB®.

- [Endpoint management commands](#endpoint-management-commands)
- [Create a new Instance endpoint](#create-a-new-instance-endpoint)
- [Delete a Database Instance endpoint](#delete-a-database-instance-endpoint)
- [Instance management commands](#instance-management-commands)
- [Create a MongoDB® Database Instance](#create-a-mongodb®-database-instance)
- [Delete a MongoDB® Database Instance](#delete-a-mongodb®-database-instance)
Expand All @@ -21,6 +23,7 @@ This API allows you to manage your Managed Databases for MongoDB®.
- [Restore a Database Instance snapshot](#restore-a-database-instance-snapshot)
- [Update a Database Instance snapshot](#update-a-database-instance-snapshot)
- [User management commands](#user-management-commands)
- [Create an user on a Database Instance](#create-an-user-on-a-database-instance)
- [Delete a user on a Database Instance](#delete-a-user-on-a-database-instance)
- [List users of a Database Instance](#list-users-of-a-database-instance)
- [Apply user roles](#apply-user-roles)
Expand All @@ -33,15 +36,47 @@ This API allows you to manage your Managed Databases for MongoDB®.

Instance endpoints enable connection to your instance.

Instance endpoints enable connection to your instance.

### Create a new Instance endpoint

Create a new endpoint for a MongoDB® Database Instance. You can add `public_network` or `private_network` specifications to the body of the request.

**Usage:**

```
scw mongodb endpoint
scw mongodb endpoint create <instance-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| instance-id | Required | UUID of the Database Instance |
| endpoint.private-network.private-network-id | | UUID of the Private Network |
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |



### Delete a Database Instance endpoint

Delete the endpoint of a Database Instance. You must specify the `endpoint_id` parameter of the endpoint you want to delete. Note that you might need to update any environment configurations that point to the deleted endpoint.

**Usage:**

```
scw mongodb endpoint delete <endpoint-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| endpoint-id | Required | UUID of the Endpoint to delete |
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |



## Instance management commands

Expand Down Expand Up @@ -375,6 +410,28 @@ scw mongodb snapshot update <snapshot-id ...> [arg=value ...]
Users are profiles to which you can attribute database-level permissions. They allow you to define permissions specific to each type of database usage.


### Create an user on a Database Instance

Create an user on a Database Instance. You must define the `name`, `password` of the user and `instance_id` parameters in the request.

**Usage:**

```
scw mongodb user create [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| instance-id | Required | UUID of the Database Instance the user belongs to |
| name | | Name of the database user |
| password | | Password of the database user |
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |



### Delete a user on a Database Instance

Delete an existing user on a Database Instance.
Expand Down
121 changes: 121 additions & 0 deletions internal/namespaces/mongodb/v1alpha1/mongodb_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ func GetGeneratedCommands() *core.Commands {
mongodbSnapshotList(),
mongodbSnapshotDelete(),
mongodbUserList(),
mongodbUserCreate(),
mongodbUserUpdate(),
mongodbUserDelete(),
mongodbUserSetRole(),
mongodbEndpointDelete(),
mongodbEndpointCreate(),
)
}

Expand Down Expand Up @@ -894,6 +897,50 @@ func mongodbUserList() *core.Command {
}
}

func mongodbUserCreate() *core.Command {
return &core.Command{
Short: `Create an user on a Database Instance`,
Long: `Create an user on a Database Instance. You must define the ` + "`" + `name` + "`" + `, ` + "`" + `password` + "`" + ` of the user and ` + "`" + `instance_id` + "`" + ` parameters in the request.`,
Namespace: "mongodb",
Resource: "user",
Verb: "create",
// Deprecated: false,
ArgsType: reflect.TypeOf(mongodb.CreateUserRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "instance-id",
Short: `UUID of the Database Instance the user belongs to`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "name",
Short: `Name of the database user`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "password",
Short: `Password of the database user`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*mongodb.CreateUserRequest)

client := core.ExtractClient(ctx)
api := mongodb.NewAPI(client)

return api.CreateUser(request)
},
}
}

func mongodbUserUpdate() *core.Command {
return &core.Command{
Short: `Update a user on a Database Instance`,
Expand Down Expand Up @@ -1046,3 +1093,77 @@ func mongodbUserSetRole() *core.Command {
},
}
}

func mongodbEndpointDelete() *core.Command {
return &core.Command{
Short: `Delete a Database Instance endpoint`,
Long: `Delete the endpoint of a Database Instance. You must specify the ` + "`" + `endpoint_id` + "`" + ` parameter of the endpoint you want to delete. Note that you might need to update any environment configurations that point to the deleted endpoint.`,
Namespace: "mongodb",
Resource: "endpoint",
Verb: "delete",
// Deprecated: false,
ArgsType: reflect.TypeOf(mongodb.DeleteEndpointRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "endpoint-id",
Short: `UUID of the Endpoint to delete`,
Required: true,
Deprecated: false,
Positional: true,
},
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*mongodb.DeleteEndpointRequest)

client := core.ExtractClient(ctx)
api := mongodb.NewAPI(client)
e = api.DeleteEndpoint(request)
if e != nil {
return nil, e
}

return &core.SuccessResult{
Resource: "endpoint",
Verb: "delete",
}, nil
},
}
}

func mongodbEndpointCreate() *core.Command {
return &core.Command{
Short: `Create a new Instance endpoint`,
Long: `Create a new endpoint for a MongoDB® Database Instance. You can add ` + "`" + `public_network` + "`" + ` or ` + "`" + `private_network` + "`" + ` specifications to the body of the request.`,
Namespace: "mongodb",
Resource: "endpoint",
Verb: "create",
// Deprecated: false,
ArgsType: reflect.TypeOf(mongodb.CreateEndpointRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "instance-id",
Short: `UUID of the Database Instance`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "endpoint.private-network.private-network-id",
Short: `UUID of the Private Network`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*mongodb.CreateEndpointRequest)

client := core.ExtractClient(ctx)
api := mongodb.NewAPI(client)

return api.CreateEndpoint(request)
},
}
}
Loading