getUserPolicy method

Future<GetUserPolicyResponse> getUserPolicy({
  1. required String policyName,
  2. required String userName,
})

Retrieves the specified inline policy document that is embedded in the specified IAM user. An IAM user can also have managed policies attached to it. To retrieve a managed policy document that is attached to a user, use GetPolicy to determine the policy's default version. Then use GetPolicyVersion to retrieve the policy document.

For more information about policies, see Managed Policies and Inline Policies in the IAM User Guide.

May throw NoSuchEntityException. May throw ServiceFailureException.

Parameter policyName : The name of the policy document to get.

This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

Parameter userName : The name of the user who the policy is associated with.

This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

Implementation

Future<GetUserPolicyResponse> getUserPolicy({
  required String policyName,
  required String userName,
}) async {
  ArgumentError.checkNotNull(policyName, 'policyName');
  _s.validateStringLength(
    'policyName',
    policyName,
    1,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(userName, 'userName');
  _s.validateStringLength(
    'userName',
    userName,
    1,
    128,
    isRequired: true,
  );
  final $request = <String, dynamic>{};
  $request['PolicyName'] = policyName;
  $request['UserName'] = userName;
  final $result = await _protocol.send(
    $request,
    action: 'GetUserPolicy',
    version: '2010-05-08',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['GetUserPolicyRequest'],
    shapes: shapes,
    resultWrapper: 'GetUserPolicyResult',
  );
  return GetUserPolicyResponse.fromXml($result);
}