Queries the information of a policy.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes GetPolicy

The operation that you want to perform. Set the value to GetPolicy.

PolicyName String Yes OSS-Administrator

The name of the policy.

The name must be 1 to 128 characters in length and can contain letters, digits, and hyphens (-).

PolicyType String Yes Custom

The type of the policy. Valid values:

  • Custom: custom policy
  • System: system policy
Language String No zh-CN

The language that is used to return the description of the system policy. Valid values:

  • en: English
  • zh-CN: Chinese
  • ja: Japanese

Response parameters

Parameter Type Example Description
Policy Struct

The information of the policy.

AttachmentCount Integer 0

The number of times the policy is referenced.

CreateDate String 2015-01-23T12:33:18Z

The time when the policy was created.

DefaultVersion String v1

The default version of the policy.

Description String OSS administrator

The description of the policy.

PolicyDocument String { "Statement": [{ "Action": ["oss:*"], "Effect": "Allow", "Resource": ["acs:oss:*:*:*"]}], "Version": "1"}

The document of the policy.

PolicyName String OSS-Administrator

The name of the policy.

PolicyType String Custom

The type of the policy. Valid values:

  • Custom: custom policy
  • System: system policy
UpdateDate String 2016-01-23T12:33:18Z

The time when the policy was updated.

RequestId String 697852FB-50D7-44D9-9774-530C31EAC572

The ID of the request.

Examples

Sample requests

https://resourcemanager.aliyuncs.com/?Action=GetPolicy
&PolicyName=OSS-Administrator
&PolicyType=Custom
&<Common request parameters>

Sample success responses

XML format

<GetPolicyResponse>
      <RequestId>697852FB-50D7-44D9-9774-530C31EAC572</RequestId>
      <Policy>
            <PolicyName>OSS-Administrator</PolicyName>
            <PolicyType>Custom</PolicyType>
            <Description>OSS administrator</Description>
            <DefaultVersion>v1</DefaultVersion>
            <PolicyDocument>{ "Statement": [{ "Action": ["oss:*"], "Effect": "Allow", "Resource": ["acs:oss:*:*:*"]}], "Version": "1"}</PolicyDocument>
            <CreateDate>2015-01-23T12:33:18Z</CreateDate>
            <UpdateDate>2016-01-23T12:33:18Z</UpdateDate>
            <AttachmentCount>0</AttachmentCount>
      </Policy>
</GetPolicyResponse>

JSON format

{
    "RequestId": "697852FB-50D7-44D9-9774-530C31EAC572",
    "Policy": {
        "PolicyName": "OSS-Administrator",
        "PolicyType": "Custom",
        "Description": "OSS administrator",
        "DefaultVersion": "v1",
        "PolicyDocument": "{ \"Statement\": [{ \"Action\": [\"oss:*\"], \"Effect\": \"Allow\", \"Resource\": [\"acs:oss:*:*:*\"]}], \"Version\": \"1\"}",
        "CreateDate": "2015-01-23T12:33:18Z",
        "UpdateDate": "2016-01-23T12:33:18Z",
        "AttachmentCount": 0
    }
}

Error codes

HTTP status code Error code Error message Description
400 InvalidParameter.PolicyType The specified policy type is invalid. The error message returned because the policy type is invalid.
400 InvalidParameter.PolicyName.InvalidChars The policy name contains invalid characters. It must only contain upper or lower case letters, numbers, and dash (-). The error message returned because the policy name contains invalid characters. The policy name can only contain letters, digits, and hyphens (-).
400 InvalidParameter.PolicyName.Length The length of the policy name is invalid. It must be 1 to 64 characters in length. The error message returned because the length of the policy name is invalid. The policy name must be 1 to 64 characters in length.
404 EntityNotExist.Policy The policy does not exist. The error message returned because the policy does not exist.

For a list of error codes, visit the API Error Center.