attachPolicy method

Future<void> attachPolicy({
  1. required String policyName,
  2. required String target,
})

Attaches a policy to the specified target.

May throw ResourceNotFoundException. May throw InvalidRequestException. May throw ThrottlingException. May throw UnauthorizedException. May throw ServiceUnavailableException. May throw InternalFailureException. May throw LimitExceededException.

Parameter policyName : The name of the policy to attach.

Parameter target : The identity to which the policy is attached.

Implementation

Future<void> attachPolicy({
  required String policyName,
  required String target,
}) async {
  ArgumentError.checkNotNull(policyName, 'policyName');
  _s.validateStringLength(
    'policyName',
    policyName,
    1,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(target, 'target');
  final $payload = <String, dynamic>{
    'target': target,
  };
  await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/target-policies/${Uri.encodeComponent(policyName)}',
    exceptionFnMap: _exceptionFns,
  );
}