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

Querying Details About Database Users

Description

This API is used to query details about database users.

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-user/detail?offset ={offset}&limit={limit}&user_name={user_name }&db_name={db_name}

  • URI example
    • Querying details about database users

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

    • Querying the user list based on specified conditions.

      https://dds.ap-southeast-1.myhuaweicloud.com/v3/0483b6b16e954cb88930a360d2c4e663/instances/3527b6b16e7639b88930a360d2c4in02/db-user/detail?offset=0&limit=100&user_name=test&db_name=testDb

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.

user_name

String

No

The username.

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 name of the database where the user is located. 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

    users

    String

    Yes

    The information about database users.

    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 users.

  • Response example
    {
      "total_count": 1,
      "users": "[{\"inheritedPrivileges\":[{\"resource\":{\"collection\":\"temproles\",\"db\":\"admin\"},\"actions\":[\"find\"]}],\"roles\":[{\"role\":\"root\",\"db\":\"admin\"}],\"inheritedRoles\":[{\"role\":\"root\",\"db\":\"admin\"}],\"_id\":\"admin.rwuser\",\"user\":\"rwuser\",\"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.