getRolePolicy method

Future<GetRolePolicyResponse> getRolePolicy({
  1. required String policyName,
  2. required String roleName,
})

Retrieves the specified inline policy document that is embedded with the specified IAM role. An IAM role can also have managed policies attached to it. To retrieve a managed policy document that is attached to a role, 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.

For more information about roles, see Using Roles to Delegate Permissions and Federate Identities.

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 roleName : The name of the role associated with the policy.

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<GetRolePolicyResponse> getRolePolicy({
  required String policyName,
  required String roleName,
}) async {
  ArgumentError.checkNotNull(policyName, 'policyName');
  _s.validateStringLength(
    'policyName',
    policyName,
    1,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(roleName, 'roleName');
  _s.validateStringLength(
    'roleName',
    roleName,
    1,
    64,
    isRequired: true,
  );
  final $request = <String, dynamic>{};
  $request['PolicyName'] = policyName;
  $request['RoleName'] = roleName;
  final $result = await _protocol.send(
    $request,
    action: 'GetRolePolicy',
    version: '2010-05-08',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['GetRolePolicyRequest'],
    shapes: shapes,
    resultWrapper: 'GetRolePolicyResult',
  );
  return GetRolePolicyResponse.fromXml($result);
}