Create Policy

Last Updated on : 2023-10-09 08:05:56download

Create a policy.

  • Allow action rules and Deny action rules cannot both be empty.
  • A maximum of 100 policies can be created for one tenant.

API address

POST: /v2.0/cloud/iam/policy

Request parameter

Description of body

Parameter nameTypeINRequiredDescription
nameString trueThe name of the specified policy.
allow_actionList falseThe Allow action, which describes the specific actions allowed.
deny_actionList falseThe Deny action, which describes the specific actions denied.
descriptionString trueThe description of the specified policy.

Return parameter

Parameter nameTypeDescription
resultLongThe ID of the created policy.
successBooleanIndicates whether the request is successful. Valid values:
  • true: The operation succeeded.
  • false: The operation failed.
error_codeStringFor more information, see the error codes.
error_msgStringThe message that is returned if the request fails. It is empty if the request is successful.

Request example

POST: /v2.0/cloud/iam/policy
{
  "name": "Policy Name",
  "description": "Policy description",
  "allow_action": [
    "device:get:state"
  ],
  "deny_action": [
    "device:get:shadow"
  ]
}

Return example

{
    "tid": "16867994844221686799484422",
    "result": 1,
    "t": 1686799484422,
    "success": true
}

Error code

For more information, see error code.