You need to enable JavaScript to run this app.
导航
UpdateGrantsForUser - 更新用户授权
最近更新时间:2024.10.09 17:05:55首次发布时间:2024.10.09 17:01:20

更新用户授予的角色和权限

请求参数

下表仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数

参数
类型
是否必填
示例值
描述
Action
String

UpdateGrantsForUser

要执行的操作,取值:UpdateGrantsForUser。

Version
String

2024-08-31

API的版本,取值:2024-08-31。

Username
String

user1

用户名

ActionType
String

GRANT

权限操作,取值为"GRANT"或者"REVOKE"

Grants
Array of Object

[
{
"Privileges": [
{
"Name": "SELECT",
"Columns": [
"column1"
]
}
],
"Targets": [
{
"database": "db1",
"table": "tb1"
}
],
"OnCluster": "cluster1",
"ClusterID": 721,
"GrantOption": true,
"GrantTo": "user1",
"RawSql": "grant sql"
}
]

授予的角色,与Assignments不能同时为空

Assignments
Array of Object

[
{
"RoleID": 123456,
"RoleName": "role1",
"RoleIsDefault": true,
"OnCluster": "cluster1",
"ClusterID": 12345,
"AdminOption": true,
"GrantTo": "user1",
"RawSql": "grant sql",
"Immutable": true,
"ImmutableReason": "aESvn0O8hBC"
}
]

授予的权限,与Grants不能同时为空

返回参数

下表仅列出本接口特有的返回参数。更多信息请参见返回结构

参数
类型
示例值
描述
Message
String

top网关响应信息

Data
Object

{ "Message": "successfully update grants for user1" }

返回数据

请求示例

POST /?Action=UpdateGrantsForUser&Version=2024-08-31 HTTP/1.1
Host: open.volcengineapi.com
Content-Type: application/json; charset=UTF-8
X-Date: 20240912T043933Z
X-Content-Sha256: 287e874e******d653b44d21e
Authorization: HMAC-SHA256 Credential=Adfks******wekfwe/20240912/cn-beijing/bytehouse_ce/request, SignedHeaders=host;x-content-sha256;x-date, Signature=47a7d934ff7b37c03938******cd7b8278a40a1057690c401e92246a0e41085f

{
  "Username": "user1",
  "ActionType": "GRANT",
  "Grants": [
    {
      "Privileges": [
        {
          "Name": "SELECT",
          "Columns": [
            "column1"
          ]
        }
      ],
      "Targets": [
        {
          "Database": "db1",
          "Table": "tb1"
        }
      ],
      "OnCluster": "cluster1",
      "ClusterID": 673,
      "GrantOption": true,
      "GrantTo": "user1",
      "RawSql": "grant sql"
    }
  ],
  "Assignments": [
    {
      "RoleID": 123456,
      "RoleName": "role1",
      "RoleIsDefault": true,
      "OnCluster": "cluster1",
      "ClusterID": 12345,
      "AdminOption": true,
      "GrantTo": "user1",
      "RawSql": "grant sql",
      "Immutable": true,
      "ImmutableReason": "QWg"
    }
  ]
}

返回示例

{
  "ResponseMetadata": {
    "RequestId": "202409121240170520760551000644EA",
    "Action": "UpdateGrantsForUser",
    "Version": "2024-08-31",
    "Service": "bytehouse_ce",
    "Region": "cn-beijing"
  },
  "Result": {
    "Message": "",
    "Data": {
      "Message": "successfully update grants for admin1"
    }
  }
}

错误码

下表为您列举了该接口与业务逻辑相关的错误码。公共错误码请参见公共错误码文档。

状态码
错误码
错误信息
说明
400
Bad Request
api service received invalid request format

参数错误

401
SignatureNotMatch
The request signature provided is incorrect.
500
InternalError
The request has failed due to an unknown error.
503
ServiceUnavailable
The request has failed due to a temporary failure of the server.