Updated on 2024-08-08 GMT+08:00

Creating a Database Account

Function

This API is used to create a database account for a GeminiDB Redis instance.

Constraints

  • Only the GeminiDB Redis API is supported.
  • This operation cannot be performed when the instance is in any of the following states: creating, changing specifications, changing database port, frozen, or abnormal.

URI

POST /v3/{project_id}/redis/instances/{instance_id}/db-users

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID of a tenant in a region. To obtain this value, see Obtaining a Project ID.

instance_id

Yes

String

Instance ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

users

No

Array of objects

All accounts to be created. For details, see Table 4.

Table 4 UserForCreation

Parameter

Mandatory

Type

Description

name

Yes

String

Account name. This parameter cannot be empty. It must start with a letter and contain up to 36 characters, including only numbers, letters, hyphens (-), and underscores (_).

password

Yes

String

  • Account password. The password can contain 8 to 32 characters.
  • The password must contain at least two of the following types: uppercase letters, lowercase letters, digits, and special characters. The following special characters are allowed: ~!@#%^*-_=+?$()&

Minimum length: 8 characters

Maximum length: 32 characters

databases

Yes

Array of strings

All databases that the account has operation permissions for. Specify at least one database or set this parameter to all, indicating that all databases are selected.

privilege

Yes

String

Account permissions. The value can be:

  • ReadOnly, indicating that the account has read-only permissions.
  • ReadWrite, indicating that the account has read and write permissions.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

job_id

String

Task ID.

Example Requests

  • URI example
    POST https://gaussdb-nosql.ap-southeast-1.myhuaweicloud.com/v3/0549b4a43100d4f32f51c01c2fe4acdb/redis/054e292c9880d4992f02c0196d3ein12/db-users
  • Creating 2 database accounts (Set name of the first account to redis1, password to ****, privilege to ReadOnly, and databases to [ "1", "2" ].
    { 
      "users" : [ { 
        "name" : "redis1", 
        "password" : "****", 
        "privilege" : "ReadOnly", 
        "databases" : [ "1", "2" ] 
      }, { 
        "name" : "redis2", 
        "password" : "****", 
        "privilege" : "ReadOnly", 
        "databases" : [ "1", "2" ] 
      } ] 
    }

Example Responses

Status code: 200

Success

{ 
  "job_id" : "f85104b5-4a9c-4e0f-9505-fc5409d8f7ae" 
}

Status Codes

For details, see Status Codes.

Error Codes

For details, see Error Codes.