Updated on 2023-11-24 GMT+08:00

Querying the Database Role List

Description

This API is used to query the database role list.

Restrictions

  • This API applies only to DDS Community Edition.
  • This operation is not allowed if the DB instance is in any of the following statuses: creating, changing instance class, changing port, restarting, or abnormal.

URI

  • URI format

    GET https://{Endpoint}/v3/{project_id}/instances/{instance_id}/db-roles?role_name={role_name}&db_name={db_name}&offset={offset}&limit={limit}

  • URI example
    • Querying the database role list

      https://dds.ap-southeast-1.myhuaweicloud.com/v3/0483b6b16e954cb88930a360d2c4e663/instances/3527b6b16e7639b88930a360d2c4in02/db-roles

    • Querying the list of roles based on specified conditions:

      https://dds.ap-southeast-1.myhuaweicloud.com/v3/0483b6b16e954cb88930a360d2c4e663/instances/3527b6b16e7639b88930a360d2c4in02/db-roles?role_name=testRole&db_name=testDb&offset=0&limit=100

Table 1 Parameter description

Name

Type

Mandatory

Description

X-Auth-Token

String

Yes

User token obtained from IAM. For details, see Authentication.

project_id

String

Yes

Project ID of a tenant in a region. To obtain the project ID, see Obtaining a Project ID.

instance_id

String

Yes

The instance ID, which can be obtained by calling the API for querying instances. If you do not have an instance, you can call the API used for creating an instance.

role_name

String

No

The role name.

The value must be 1 to 64 characters and can contain only letters (from A to Z or from a to z), digits (from 0 to 9), hyphens (-), and periods (.).

db_name

String

No

The database name. The default value is "admin".

The value must be 1 to 64 characters and can contain only letters (from A to Z or from a to z), digits (from 0 to 9), and underscores (_).

offset

Integer

No

The index position.

The value must be greater than or equal to 0. If this parameter is not transferred, the value is 0 by default.

limit

Integer

No

The upper limit of the number of queried records.

The value ranges from 1 to 100. If this parameter is not transferred, the first 100 DB instances are queried by default.

Requests

None

Responses

  • Parameter description
    Table 2 Parameter description

    Name

    Type

    Mandatory

    Description

    roles

    String

    Yes

    The database role information.

    CAUTION:

    The return value is in the native format of the database and needs to be parsed by the user.

    total_count

    Integer

    Yes

    The total number of database roles.

  • Response example
    {
      "total_count": 1,
      "roles": "[{\"privileges\":[{\"resource\":{\"collection\":\"\",\"db\":\"admin\"},\"actions\":[\"viewUser\"]}],\"inheritedPrivileges\":[{\"resource\":{\"collection\":\"\",\"db\":\"admin\"},\"actions\":[\"viewUser\"]}],\"role\":\"userAdmin\",\"roles\":[],\"inheritedRoles\":[],\"isBuiltin\":true,\"db\":\"admin\"}]"
    }

SDK

Click Document Database Service DDS SDK to download the SDK or view the SDK document. To learn how to install and authenticate an SDK, read the Usage section.

Status Code

For more information, see Status Code.

Error Code

For more information, see Error Code.