Grant object privileges to a role

2023-08-22 02:51:01  Updated

Description

You can call this operation to grant object privileges to a role.

Call description

Prerequisites

You have passed the authentication for the OCP application service.

You have the Update permission on the specified tenant.

Request path

POST /api/v2/ob/clusters/{id}/tenants/{tenantId}/roles/{roleName}/grantObjectPrivilege

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.
roleName String Yes ROLE1 The role name.

Request body parameters

Parameter Type Required Example value Description
objectPrivileges Array Yes -- The list of object privileges to be granted.
├─ dbObject Object Yes -- The database object.
├─ privileges StringArray Yes [SELECT, UPDATE] The list of object privileges.

dbObject parameters

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

Response parameters

Parameter Type Description
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 application server that responded to the request.

Examples

Sample request

Grant the SELECT and UPDATE privileges on Table U1.T1 to ROLE1 in Tenant 1000001 of Cluster 1.

POST /api/v2/ob/clusters/1/tenants/2000001/roles/ROLE1/grantObjectPrivilege?id=1&tenantId=2000001&username=USER1

{
  "objectPrivileges": [
    {
      "object": {
        "objectType": "TABLE",
        "objectName": "T1",
        "schemaName": "U1",
      },
      "privileges": [
        "SELECT",
        "UPDATE"
      ]
    }
  ]
}

Sample response

{
  "duration": 201,
  "server": "xx.xx.xx.xx",
  "status": 200,
  "successful": true,
  "timestamp": "2021-09-07T15:30:41.205+08:00",
  "traceId": "f4783564b21746db"
}

Contact Us