Apply data privileges¶
Submits data access changes for the specified role. The interface synchronously executes permission changes and result verification, and returns the final status of this operation. Confirm whether authorization is completed based on the processing results of each resource.
PUT $CLOUDSIGMA_API_BASE/workspaces/{workspace_id}/iam/roles/{role_id}/data-privileges
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. First select the character. Then Query the role data permissions, confirm the current authorization status and prepare changes based on the latest status.
Prepare personal access token and target workspace ID with corresponding permissions for the target workspace.
Request body¶
Replace $WORKSPACE_ID, $ROLE_ID, $CLOUDSIGMA_API_KEY in the example with actual values.
curl -X PUT "$CLOUDSIGMA_API_BASE/workspaces/$WORKSPACE_ID/iam/roles/$ROLE_ID/data-privileges" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"request_id": "req-001",
"expected_data_privilege_version": 1,
"mutations": [
{
"operation": "grant",
"action_id": "table.query",
"resource_type": "table",
"resource_id": "1001",
"privilege": "select",
"with_grant_option": false,
"row_column": {
"mode": "keep"
}
}
]
}'
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Target workspace ID. |
|
string |
Yes |
The role ID of the data permissions to be updated. |
Request body
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
The idempotent request ID generated by the caller is also the original request ID used in subsequent viewing operations. Cannot be empty. |
|
integer |
No |
Data permission version used by concurrency checking. The default value is 0, which cannot be less than 0. |
|
array of object |
Yes |
The permission changes to be performed must contain at least 1 items. |
|
string |
When the object is provided |
Change type, which can only be grant or revoke. Value: |
|
string |
When the object is provided |
The data operation ID in the permission schema. |
|
string |
When the object is provided |
Resource type, which can only be database or table. Value: |
|
string |
When the object is provided |
The resource ID of the database or table. |
|
string |
When the object is provided |
OmniFabric permission name. Values: |
|
boolean |
No |
Omit this field or send false. true is currently rejected. |
|
object or null |
When table SELECT grant |
Table-level row and column rules. Submit only if you need to set, clear, or preserve row and column rules. |
|
string |
When row_column is provided |
Column and column rule processing methods: keep, set or clear. Values: |
|
object |
When mode=set |
The row and column rules submitted when mode is set. |
|
array of string or null |
No |
A set of prohibited columns. |
|
array of object or null |
No |
Row filtering rules. |
|
string |
No |
Column name. |
|
string |
No |
Conditional connection relationship. Value: |
|
array of object or null |
No |
SQL expression rules. |
|
string |
No |
Comparison operators. Values: |
|
array of string or null |
No |
List of conditional values. |
|
string |
No |
Value matching type. Values: empty string, |
with_grant_option can only be omitted or filled in with false. Filling in true will be rejected. This option does not support OmniFabric permission delegation. grant.* in application permissions uses another delegation mechanism.
row_column must be provided when granting SELECT permissions on the table. Retaining existing rules also requires submitting {"mode":"keep"}. This field can be omitted or clear used when revoking permissions. Other permissions do not accept row and column rules.
draft must be provided when mode=set, and fill in the prohibited columns (black_column_list) and row filtering rules (rule_list) according to the above request body fields. rule_list is grouped by column, relation uses and or or. The operator of expression_list must be compatible with the matching type, and expression cannot be empty. Only one value can be provided except in and not in.
After the service validates the SQL expression, it uses the expression in the rule. SQL expression cannot be used as resource ID. The actual use of row and column rules also requires database support.
Use the database and table IDs returned by the resource selection interface. The ID must be a positive decimal string in the range int64 without leading zeros, symbols, or spaces. table-001, table names, and UUIDs are not substitutes for resource IDs.
Successful response¶
{
"code": "OK",
"msg": "OK",
"data": {
"request_id": "req-001",
"trace_id": "trace-001",
"operation_id": "operation-001",
"audit_event_id": "audit-001",
"state": "succeeded",
"data_privilege_version": 2,
"idempotent_replay": false,
"session_invalidation_status": "new_connections_only",
"matrixone_fact_version": "fact-v2",
"resource_results": [
{
"resource_type": "table",
"resource_id": "1001",
"action_id": "table.query",
"privilege_key": "select",
"operation": "grant",
"state": "succeeded",
"session_invalidation_status": "new_connections_only",
"matrixone_fact_version": "example",
"error_code": ""
}
]
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
Original request ID, used to view this operation. |
|
string |
Link tracking ID. |
|
string |
Operation ID generated by the server. |
|
string |
Audit event ID. |
|
string |
The final status of this synchronization operation. Values: |
|
integer |
Data permission version after operation. |
|
boolean |
Whether it is an idempotent replay of the same request. |
|
string |
Session permission refresh status. Values: |
|
string |
OmniFabric permissions fact version. |
|
array of object |
Permission enforcement results for each resource. At least 1 items. |
|
string |
Resource type. Value: |
|
string |
Resource ID. |
|
string |
Permission actions. |
|
string |
Permission key. Values: |
|
string |
operation. Value: |
|
string |
Running status. Values: |
|
string |
Session permission update status. Values: |
|
string |
MatrixOne permissions fact version. |
|
string |
error code. Values: empty string, |
Continue to track changes
Use the identifier of this change query data permission change results. When unknown is returned or the result is unclear, first use the original request identifier to query the existing operation instead of directly creating a new change request.
Error response¶
{
"code": "ErrParamInvalid",
"msg": "请求参数无效",
"data": null
}
Field |
Type |
Description |
|---|---|---|
code |
string |
error code. |
msg |
string |
error message. |
data |
null |
—。 |