get_user_policy ( $user_name, $policy_name, $opt )

Retrieves the specified policy document for the specified user. The returned policy is URL-encoded according to RFC 3986. For more information about RFC 3986, go to http://www.faqs.org/rfcs/rfc3986.html.

Access

public

Parameters

Parameter

Type

Required

Description

$user_name

string

Required

Name of the user who the policy is associated with. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: [\w+=,.@-]*]

$policy_name

string

Required

Name of the policy document to get. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: [\w+=,.@-]*]

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Get an existing user policy.

// Instantiate the class
$iam = new AmazonIAM();

$response = $iam->get_user_policy('johndoe2', 'user-policy');

if ($response->isOK() && $response->body->PolicyDocument(0))
{
	$policy_document = (string) $response->body->PolicyDocument(0);
	$policy_object = CFPolicy::decode_policy($policy_document);

	print_r($policy_object);
}
Result:
Array
(
    [Statement] => Array
        (
            [0] => Array
                (
                    [Effect] => Allow
                    [Action] => *
                    [Resource] => *
                )

        )

)

Related Methods

Source

Method defined in services/iam.class.php | Toggle source view (8 lines) | View on GitHub

public function get_user_policy($user_name, $policy_name, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['UserName'] = $user_name;
    $opt['PolicyName'] = $policy_name;
    
    return $this->authenticate('GetUserPolicy', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback