Query the list of database users

2024-11-06 03:13:28  Updated

Description

You can call this operation to query the list of database users.

Call description

Prerequisites

You have passed the authentication for the OCP application service.

You have the Read permission on the specified tenant.

Request path

GET /api/v2/ob/clusters/{id}/tenants/{tenantId}/users

Request parameters

path parameters

Parameter Type Required Example value Description
id Integer Yes 1 The ID of the cluster.
tenantId Integer Yes 5 The ID of the tenant.

Response parameters

Parameter Type Description
data Object Contents are included.
├─ contents Array The list of database users. For more information about the data structure, see the following table.
successful Boolean Indicates whether the request was successful.
timestamp Datetime The timestamp when the server completed the request.
duration Integer The time taken by the server to process the request, in milliseconds.
status Integer An HTTP status code.
traceId String The trace ID of the request. This trace ID is used for troubleshooting.
server String The address of the server that responded to the request.

Data structure of database user information

Parameter Type Description
username String The username.
globalPrivileges StringArray The list of global privileges. * For MySQL tenants, it is a list of global privileges. * For Oracle tenants, it is a list of system privileges.
dbPrivileges Array The list of database privileges. Note This parameter is available only in MySQL tenants.
├─ dbName String The name of the database.
├─ privileges StringArray The list of database privileges.
objectPrivileges Array The list of object privileges. Note This parameter is available only in Oracle tenants.
├─ dbObject Object The database object. For more information, see dbObject parameters.
├─ privileges StringArray The list of object privileges.
grantedRoles StringArray The roles granted to the user. Note This parameter is available only in Oracle tenants.
isLocked Bool Indicates whether the user has been locked.
createTime Datetime The time when the user account was created.
connectionStrings Array The list of OBProxies and connection strings.
├─ connectionStringType String The type of the connection string. Valid values: * OBPROXY * DIRECT
├─ obProxyAddress String The IP address of the OBProxy. Note This parameter is valid only when the connection string type is OBProxy.
├─ obProxyPort Integer The port number of the OBProxy. Note This parameter is valid only when the connection string type is OBProxy.
├─ connectionString String The connection string.
accessibleDatabases StringArray The accessible database. Note This parameter is available only in MySQL tenants.

dbObject parameters

Parameter Type Description
objectType String The type of the database object. Valid values: * TABLE * VIEW * STORED_PROCEDURE
objectName String The name of the database object, namely, the name of the table, view, or stored procedure.
schemaName String The schema name, which is generally the same as the username.

Examples

Sample request

Query users in Tenant 1000001 of Cluster 1.

GET /api/v2/ob/clusters/1/tenants/1000001/users?id=1&tenantId=1000001

Sample response

{
  "data": {
    "contents": [
      {
        "accessibleDatabases": [
          "oceanbase",
          "information_schema",
          "mysql",
          "test",
          "db1"
        ],
        "connectionStrings": [
          {
            "connectionString": "mysql -hxx.xx.xx.xx -P2881 -uroot@mysql1 -p",
            "type": "DIRECT"
          }
        ],
        "createTime": "2021-09-06T11:38:44.585445+08:00",
        "dbPrivileges": [
          {
            "dbName": "mysql",
            "privileges": [
              "SELECT",
              "INSERT",
              "UPDATE",
              "DELETE",
              "CREATE",
              "DROP",
              "INDEX",
              "ALTER",
              "CREATE_VIEW",
              "SHOW_VIEW"
            ]
          },
          {
            "dbName": "oceanbase",
            "privileges": [
              "SELECT",
              "INSERT",
              "UPDATE",
              "DELETE",
              "CREATE",
              "DROP",
              "INDEX",
              "ALTER",
              "CREATE_VIEW",
              "SHOW_VIEW"
            ]
          },
          {
            "dbName": "test",
            "privileges": [
              "SELECT",
              "INSERT",
              "UPDATE",
              "DELETE",
              "CREATE",
              "DROP",
              "INDEX",
              "ALTER",
              "CREATE_VIEW",
              "SHOW_VIEW"
            ]
          },
          {
            "dbName": "information_schema",
            "privileges": [
              "SELECT",
              "INSERT",
              "UPDATE",
              "DELETE",
              "CREATE",
              "DROP",
              "INDEX",
              "ALTER",
              "CREATE_VIEW",
              "SHOW_VIEW"
            ]
          }
        ],
        "globalPrivileges": [
          "ALTER",
          "CREATE",
          "DELETE",
          "DROP",
          "GRANT_OPTION",
          "INSERT",
          "UPDATE",
          "SELECT",
          "INDEX",
          "CREATE_VIEW",
          "SHOW_VIEW",
          "SHOW_DATABASES",
          "CREATE_USER",
          "SUPER",
          "PROCESS"
        ],
        "isLocked": false,
        "username": "root".
      }
    ]
  },
  "duration": 416,
  "server": "a83ad33525",
  "status": 200,
  "successful": true,
  "timestamp": "2021-09-07T15:06:47.19+08:00",
  "traceId": "38263a4ed3f04e1c"
}

Contact Us