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.

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

Shell
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

workspace_id

string

Yes

Target workspace ID.

role_id

string

Yes

The role ID of the data permissions to be updated.

Request body

Field

Type

Required

Description

request_id

string

Yes

The idempotent request ID generated by the caller is also the original request ID used in subsequent viewing operations. Cannot be empty.

expected_data_privilege_version

integer

No

Data permission version used by concurrency checking. The default value is 0, which cannot be less than 0.

mutations

array of object

Yes

The permission changes to be performed must contain at least 1 items.

mutations[].operation

string

When the object is provided

Change type, which can only be grant or revoke. Value: grant, revoke.

mutations[].action_id

string

When the object is provided

The data operation ID in the permission schema.

mutations[].resource_type

string

When the object is provided

Resource type, which can only be database or table. Value: database, table.

mutations[].resource_id

string

When the object is provided

The resource ID of the database or table.

mutations[].privilege

string

When the object is provided

OmniFabric permission name. Values: create_table, select, insert, update, delete.

mutations[].with_grant_option

boolean

No

Omit this field or send false. true is currently rejected.

mutations[].row_column

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.

mutations[].row_column.mode

string

When row_column is provided

Column and column rule processing methods: keep, set or clear. Values: keep, set, clear.

mutations[].row_column.draft

object

When mode=set

The row and column rules submitted when mode is set.

mutations[].row_column.draft.black_column_list

array of string or null

No

A set of prohibited columns.

mutations[].row_column.draft.rule_list

array of object or null

No

Row filtering rules.

mutations[].row_column.draft.rule_list[].column

string

No

Column name.

mutations[].row_column.draft.rule_list[].relation

string

No

Conditional connection relationship. Value: and, or.

mutations[].row_column.draft.rule_list[].expression_list

array of object or null

No

SQL expression rules.

mutations[].row_column.draft.rule_list[].expression_list[].operator

string

No

Comparison operators. Values: =, !=, >, >=, <, <=, like, regexp_like, in, not in, expression.

mutations[].row_column.draft.rule_list[].expression_list[].expression

array of string or null

No

List of conditional values.

mutations[].row_column.draft.rule_list[].expression_list[].match_type

string

No

Value matching type. Values: empty string, c, i, m, n, u.

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

JSON
{
  "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

data.request_id

string

Original request ID, used to view this operation.

data.trace_id

string

Link tracking ID.

data.operation_id

string

Operation ID generated by the server.

data.audit_event_id

string

Audit event ID.

data.state

string

The final status of this synchronization operation. Values: succeeded, failed, drifted, unknown.

data.data_privilege_version

integer

Data permission version after operation.

data.idempotent_replay

boolean

Whether it is an idempotent replay of the same request.

data.session_invalidation_status

string

Session permission refresh status. Values: new_connections_only, all_sessions_refreshed, not_applicable, unknown.

data.matrixone_fact_version

string

OmniFabric permissions fact version.

data.resource_results

array of object

Permission enforcement results for each resource. At least 1 items.

data.resource_results[].resource_type

string

Resource type. Value: database, table.

data.resource_results[].resource_id

string

Resource ID.

data.resource_results[].action_id

string

Permission actions.

data.resource_results[].privilege_key

string

Permission key. Values: create_table, select, insert, update, delete.

data.resource_results[].operation

string

operation. Value: grant, revoke.

data.resource_results[].state

string

Running status. Values: succeeded, failed, drifted, unknown.

data.resource_results[].session_invalidation_status

string

Session permission update status. Values: new_connections_only, all_sessions_refreshed, not_applicable, unknown.

data.resource_results[].matrixone_fact_version

string

MatrixOne permissions fact version.

data.resource_results[].error_code

string

error code. Values: empty string, data_privilege_validation_failed, authorization_revoked, resource_changed, version_conflict, matrixone_unavailable, data_privilege_drifted, matrixone_apply_failed, decision_unknown.

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

JSON
{
  "code": "ErrParamInvalid",
  "msg": "请求参数无效",
  "data": null
}

Field

Type

Description

code

string

error code.

msg

string

error message.

data

null

—。

Last updated on