detachPrincipalPolicy method

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

Removes the specified policy from the specified certificate.

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

Requires permission to access the DetachPrincipalPolicy action.

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

Parameter policyName : The name of the policy to detach.

Parameter principal : The principal.

Valid principals are CertificateArn (arn:aws:iot:region:accountId:cert/certificateId), thingGroupArn (arn:aws:iot:region:accountId:thinggroup/groupName) and CognitoId (region:id).

Implementation

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