deleteCertificate method

Future<void> deleteCertificate({
  1. required String certificateId,
  2. bool? forceDelete,
})

Deletes the specified certificate.

A certificate cannot be deleted if it has a policy or IoT thing attached to it or if its status is set to ACTIVE. To delete a certificate, first use the DetachPrincipalPolicy API to detach all policies. Next, use the UpdateCertificate API to set the certificate to the INACTIVE status.

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

Parameter certificateId : The ID of the certificate. (The last part of the certificate ARN contains the certificate ID.)

Parameter forceDelete : Forces the deletion of a certificate if it is inactive and is not attached to an IoT thing.

Implementation

Future<void> deleteCertificate({
  required String certificateId,
  bool? forceDelete,
}) async {
  ArgumentError.checkNotNull(certificateId, 'certificateId');
  _s.validateStringLength(
    'certificateId',
    certificateId,
    64,
    64,
    isRequired: true,
  );
  final $query = <String, List<String>>{
    if (forceDelete != null) 'forceDelete': [forceDelete.toString()],
  };
  await _protocol.send(
    payload: null,
    method: 'DELETE',
    requestUri: '/certificates/${Uri.encodeComponent(certificateId)}',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
}