Update a role

Update the role name, description, application policy, and incremental database permissions. The application policy is processed as a complete replacement, and the write must match the current version.

HTTP
PATCH $CLOUDSIGMA_API_BASE/workspaces/{workspace_id}/iam/roles/{role_id}

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 role, confirm that the role still allows modification, and prepare to update based on the current status in the list.

Prepare personal access token and target workspace ID with corresponding permissions for the target workspace. Confirm the current role version and policy schema version.

Request body

Replace $WORKSPACE_ID, $ROLE_ID, $CLOUDSIGMA_API_KEY, $SCHEMA_VERSION in the example with actual values.

Shell
curl -X PATCH "$CLOUDSIGMA_API_BASE/workspaces/$WORKSPACE_ID/iam/roles/$ROLE_ID" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
  "request_id": "req-001",
  "name": "数据分析师",
  "description": "负责查看分析数据",
  "expected_lifecycle_version": 1,
  "schema_version": "'"$SCHEMA_VERSION"'",
  "expected_policy_version": 1
}'

Parameter

Type

Required

Description

workspace_id

string

Yes

Target workspace ID.

role_id

string

Yes

Target role ID.

Request body

Field

Type

Required

Description

name

string

Yes

Character name. Cannot be empty.

description

string

No

Updated character descriptions. Saves as an empty string when omitted.

schema_version

string

Yes

Policy schema version. Cannot be empty.

request_id

string

Yes

Request ID. Cannot be empty.

expected_lifecycle_version

integer

Yes

Expected role lifecycle version, must be greater than 0.

expected_policy_version

integer

Yes

Expected application policy version. Not less than 1.

expected_data_privilege_version

integer

No

Expected data permission version. Not less than 0.

statements

array of object or null

No

Apply policy statements.

statements[].statement_id

string

No

Unique identifier for an IAM policy statement.

statements[].action_id

string

When the object is provided

Permission actions.

statements[].resource_type

string

When the object is provided

Resource type.

statements[].scope_mode

string

When the object is provided

Resource scope. Value: all, resources.

statements[].resource_id

string

No

Resource ID.

statements[].condition_hash

string

No

Summary of conditions.

statements[].target_action_id

string

No

Action is granted.

statements[].grant_scope_mode

string

No

Scope of delegation. Values: all, resources, empty string.

statements[].grant_delegatable

boolean

No

Whether to allow application permissions to be delegated again.

data_privilege_mutations

array of object or null

No

Incremental data permission changes.

data_privilege_mutations[].operation

string

When the object is provided

operation. Value: grant, revoke.

data_privilege_mutations[].action_id

string

When the object is provided

Permission actions.

data_privilege_mutations[].resource_type

string

When the object is provided

Resource type. Value: database, table.

data_privilege_mutations[].resource_id

string

When the object is provided

Resource ID.

data_privilege_mutations[].privilege

string

When the object is provided

MatrixOne permissions. Values: create_table, select, insert, update, delete.

data_privilege_mutations[].with_grant_option

boolean

No

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

data_privilege_mutations[].row_column

object or null

No

Row and column rule processing.

data_privilege_mutations[].row_column.mode

string

When row_column is provided

processing mode. Values: keep, set, clear.

data_privilege_mutations[].row_column.draft

object

When mode=set

Draft row and column rules.

data_privilege_mutations[].row_column.draft.black_column_list

array of string or null

No

A set of prohibited columns.

data_privilege_mutations[].row_column.draft.rule_list

array of object or null

No

Row filtering rules.

data_privilege_mutations[].row_column.draft.rule_list[].column

string

No

Column name.

data_privilege_mutations[].row_column.draft.rule_list[].relation

string

No

Conditional connection relationship. Value: and, or.

data_privilege_mutations[].row_column.draft.rule_list[].expression_list

array of object or null

No

SQL expression rules.

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

string

No

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

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

array of string or null

No

List of conditional values.

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

string

No

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

statement_id

string

No

Unique identifier for an IAM policy statement.

action_id

string

Yes

Permission actions.

resource_type

string

Yes

Resource type. Resource type. Value: database, table.

scope_mode

string

Yes

Resource scope. Value: all, resources.

resource_id

string

No

Resource ID.

condition_hash

string

No

Summary of conditions.

target_action_id

string

No

Action is granted.

grant_scope_mode

string

No

Scope of delegation. Values: all, resources, empty string.

grant_delegatable

boolean

No

Whether to allow application permissions to be delegated again.

operation

string

Yes

operation. Value: grant, revoke.

resource_id

string

Yes

Resource ID.

privilege

string

Yes

MatrixOne permissions. Values: create_table, select, insert, update, delete.

with_grant_option

boolean

No

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

row_column

object or null

No

Row and column rule processing.

row_column.mode

string

When row_column is provided

processing mode. Values: keep, set, clear.

row_column.draft

object

When mode=set

Draft row and column rules.

row_column.draft.black_column_list

array of string or null

No

A set of prohibited columns.

row_column.draft.rule_list

array of object or null

No

Row filtering rules.

row_column.draft.rule_list[].column

string

No

Column name.

row_column.draft.rule_list[].relation

string

No

Conditional connection relationship. Value: and, or.

row_column.draft.rule_list[].expression_list

array of object or null

No

SQL expression rules.

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

string

No

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

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

array of string or null

No

List of conditional values.

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

string

No

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

mode

string

No

processing mode. Values: keep, set, clear.

draft

object

No

Draft row and column rules.

draft.black_column_list

array of string or null

No

A set of prohibited columns.

draft.rule_list

array of object or null

No

Row filtering rules.

draft.rule_list[].column

string

No

Column name.

draft.rule_list[].relation

string

No

Conditional connection relationship. Value: and, or.

draft.rule_list[].expression_list

array of object or null

No

SQL expression rules.

draft.rule_list[].expression_list[].operator

string

No

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

draft.rule_list[].expression_list[].expression

array of string or null

No

List of conditional values.

draft.rule_list[].expression_list[].match_type

string

No

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

black_column_list

array of string or null

No

A set of prohibited columns.

rule_list

array of object or null

No

Row filtering rules.

rule_list[].column

string

No

Column name.

rule_list[].relation

string

No

Conditional connection relationship. Value: and, or.

rule_list[].expression_list

array of object or null

No

SQL expression rules.

rule_list[].expression_list[].operator

string

No

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

rule_list[].expression_list[].expression

array of string or null

No

List of conditional values.

rule_list[].expression_list[].match_type

string

No

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

column

string

No

Column name.

relation

string

No

Conditional connection relationship. Value: and, or.

expression_list

array of object or null

No

SQL expression rules.

expression_list[].operator

string

No

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

expression_list[].expression

array of string or null

No

List of conditional values.

expression_list[].match_type

string

No

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

operator

string

No

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

expression

array of string or null

No

List of conditional values.

match_type

string

No

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

Submit schema_version, request_id, expected_lifecycle_version greater than 0, and expected_policy_version. expected_data_privilege_version cannot be smaller than 0.

statements will replace the entire application policy. Omitting or filling in null or [] will clear the policy. data_privilege_mutations incrementally modifies database permissions. If omitted, the original value is retained.

Changes are implemented in stages, and compensation is attempted when failures occur. When the submission result is unclear, first query the result according to the original request, and do not use a new request to repeat the operation.

Successful response

JSON
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "role_id": "",
    "role_version": 0,
    "policy_version": 0,
    "data_privilege_version": 0,
    "session_invalidation_status": "new_connections_only",
    "idempotent_replay": false,
    "provisioning_state": "pending",
    "provisioning_version": 0,
    "provisioning_error_code": "",
    "request_id": "",
    "trace_id": ""
  }
}

Field

Type

Description

data.role_id

string

Role ID.

data.role_version

integer

Character version.

data.policy_version

integer

Apply policy version.

data.data_privilege_version

integer

Data permission version.

data.session_invalidation_status

string

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

data.idempotent_replay

boolean

Whether it is an idempotent replay of the same request.

data.provisioning_state

string

Role configuration status. Values: pending, ready, failed.

data.provisioning_version

integer

Role configuration version.

data.provisioning_error_code

string

Role configuration error code.

data.request_id

string

Request ID.

data.trace_id

string

TraceID。

Error response

Normal errors only return code and msg. When core error codes are present, data may contain request_id, trace_id, and core_error_code. Parse results by error response fields.

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

Field

Type

Description

code

string

error code.

msg

string

error message.

data

object

Only errors carrying core error codes return this object. Other errors are omitted.

data.request_id

string

Current request identifier.

data.trace_id

string

The tracking ID of the current request.

data.core_error_code

string

Core error code.

Last updated on