Validate application permission policy¶
Check whether the application permission policy for a role can be saved without modifying the current policy. A successful validation only means that the submitted policy satisfies the current rules.
POST https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/iam/roles/{role_id}/application-policy:validate
Preparation before calling¶
First select a role and confirm that its policy can be modified. Then view the permission schema to choose supported actions, resource types, and grant scopes. Finally, view the role permission view and prepare the change to validate based on the current policy state.
Prepare a personal access token with the required permissions for the target workspace and the target workspace ID.
Request parameters¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/iam/roles/$ROLE_ID/application-policy:validate" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d "{
\"schema_version\": \"$SCHEMA_VERSION\",
\"expected_policy_version\": 1,
\"expected_role_lifecycle_version\": 1,
\"request_id\": \"req-001\",
\"statements\": [
{
\"action_id\": \"workflow.read\",
\"resource_type\": \"workflow\",
\"scope_mode\": \"all\"
}
]
}"
Path parameters
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Target workspace ID. |
|
string |
Yes |
ID of the role whose policy is validated. |
Request body
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Version of the permission schema used by this policy. |
|
integer |
No |
Policy version used for concurrency checks; cannot be less than 0. |
|
integer |
Yes |
Current role lifecycle version; must be greater than 0. |
|
string |
Yes |
Caller-generated request ID. |
|
object array |
Yes |
Policy statements to validate. An empty array represents an empty policy. |
|
string |
No |
Statement ID. The service generates one when omitted. |
|
string |
Yes |
Action ID in the permission schema. |
|
string |
Yes |
Resource type that matches the action. |
|
string |
Yes |
Resource scope: |
|
string |
No |
Resource ID used when |
|
string |
No |
Hash of the condition expression. |
|
string |
No |
Target action ID when granting a permission. |
|
string |
No |
Delegable scope: |
|
boolean |
No |
Whether further delegation is allowed. |
Successful response¶
On success, returns whether the policy is valid, the hash of its normalized form, and its statement count. The policy is not written.
{
"code": "OK",
"msg": "OK",
"data": {
"valid": true,
"policy_hash": "sha256:example",
"statement_count": 1,
"request_id": "req-001",
"trace_id": "trace-001"
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
boolean |
Whether the policy passes validation. |
|
string |
Hash of the normalized policy. |
|
integer |
Number of policy statements. |
|
string |
Request correlation ID. |
|
string |
Trace ID. |
Error response¶
{
"code": "ErrParamInvalid",
"msg": "Invalid request parameters",
"data": null
}
Field |
Type |
Description |
|---|---|---|
|
string |
Error code. |
|
string |
Error message. |
|
null |
— |