attachPrincipalPolicy method

Future<void> attachPrincipalPolicy({
  1. required String policyName,
  2. required String principal,
})

Attaches the specified policy to the specified principal (certificate or other credential).

Note: This action is deprecated and works as expected for backward compatibility, but we won't add enhancements. Use AttachPolicy instead.

Requires permission to access the AttachPrincipalPolicy action.

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

Parameter policyName : The policy name.

Parameter principal : The principal, which can be a certificate ARN (as returned from the CreateCertificate operation) or an Amazon Cognito ID.

Implementation

Future<void> attachPrincipalPolicy({
  required String policyName,
  required String principal,
}) async {
  final headers = <String, String>{
    'x-amzn-iot-principal': principal.toString(),
  };
  await _protocol.send(
    payload: null,
    method: 'PUT',
    requestUri: '/principal-policies/${Uri.encodeComponent(policyName)}',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
}