Validating a Policy
Function
This API is used to validate a policy and return a list of findings.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.
|
Action |
Access Level |
Resource Type (*: required) |
Condition Key |
Alias |
Dependencies |
|---|---|---|---|---|---|
|
AccessAnalyzer::validatePolicy |
Read |
- |
- |
- |
- |
URI
POST /v5/policies/validate
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
limit |
No |
Integer |
Maximum number of results on a page Minimum: 1 Maximum: 200 Default: 100 |
|
marker |
No |
String |
Page marker Minimum: 4 Maximum: 400 |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Language |
No |
String |
Language of the returned message. The default value is 'zh-cn'.
Default: zh-cn |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
policy_document |
Yes |
String |
JSON policy document. |
|
policy_type |
Yes |
String |
Type of the policy to be validated.
|
|
validate_policy_resource_type |
No |
String |
The type of resource to attach to your resource policy.
|
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
findings |
Array of ValidatePolicyFinding objects |
Actionable recommendation that can be used to improve the policy. |
|
page_info |
PageInfo object |
Information on the page |
|
Parameter |
Type |
Description |
|---|---|---|
|
finding_details |
String |
A localized message that explains the finding and provides guidance on how to address it |
|
finding_type |
String |
Impact level.
|
|
issue_code |
String |
Provides an identifier of the issue associated with the validation check findings. |
|
learn_more_link |
String |
Links to related documents associated with the validation check findings. |
|
locations |
Array of Location objects |
List of locations that are related to the validation check findings in the policy document. |
|
Parameter |
Type |
Description |
|---|---|---|
|
path |
Array of PathElement objects |
A path in a policy, represented as a sequence of path elements |
|
span |
Span object |
Span of the cursor in a policy, consisting of a start position (inclusive) and end position (exclusive) |
|
Parameter |
Type |
Description |
|---|---|---|
|
index |
Integer |
Index in a JSON array, starting from 0 |
|
key |
String |
Key in a JSON object |
|
substring |
Substring object |
Substring of a literal string in a JSON object |
|
value |
String |
Value associated with a given key in a JSON object |
|
Parameter |
Type |
Description |
|---|---|---|
|
start |
Integer |
Start index of the substring, starting from 0. The value 0 indicates the first character. |
|
length |
Integer |
Length of the substring |
|
Parameter |
Type |
Description |
|---|---|---|
|
start |
Position object |
Position in a policy |
|
end |
Position object |
Position in a policy |
|
Parameter |
Type |
Description |
|---|---|---|
|
line |
Integer |
Line of the position, starting from 1 |
|
column |
Integer |
Column of the position, starting from 0. |
|
offset |
Integer |
Offset within the policy that corresponds to the position, starting from 0. |
|
Parameter |
Type |
Description |
|---|---|---|
|
current_count |
Integer |
Number of items on the current page |
|
next_marker |
String |
If present, it indicates that the available output is more than the output contained in the current response. Use this value in the marker request parameter in a subsequent call to the operation to get the next part of the output. You should repeat this operation until the next_marker response returns null. |
Example Requests
Requesting the validation of a policy and returning a list of findings
POST https://{hostname}/v5/policies/validate
{
"policy_document" : "",
"policy_type" : "identity_policy"
}
Example Responses
Status code: 200
OK
{
"findings" : [ {
"finding_details" : "Fix the JSON syntax error in row 1 and column 0 of index 0.",
"finding_type" : "error",
"issue_code" : "JSON_SYNTAX_ERROR",
"learn_more_link" : "https://{endpoint}/section0",
"locations" : [ {
"path" : [ ],
"span" : {
"start" : {
"line" : 1,
"column" : 0,
"offset" : 0
},
"end" : {
"line" : 1,
"column" : 1,
"offset" : 1
}
}
} ]
} ],
"page_info" : {
"current_count" : 1,
"next_marker" : null
}
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
OK |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot