기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
AWS SDK 또는 CLI와 DeleteCertificate 함께 사용
다음 코드 예시는 DeleteCertificate의 사용 방법을 보여 줍니다.
- .NET
-
- SDK for .NET (v4)
-
참고
GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리
에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요. /// <summary> /// Deletes an IoT certificate. /// </summary> /// <param name="certificateId">The ID of the certificate to delete.</param> /// <returns>True if successful, false otherwise.</returns> public async Task<bool> DeleteCertificateAsync(string certificateId) { try { // First, update the certificate to inactive state var updateRequest = new UpdateCertificateRequest { CertificateId = certificateId, NewStatus = CertificateStatus.INACTIVE }; await _amazonIoT.UpdateCertificateAsync(updateRequest); // Then delete the certificate var deleteRequest = new DeleteCertificateRequest { CertificateId = certificateId }; await _amazonIoT.DeleteCertificateAsync(deleteRequest); _logger.LogInformation($"Deleted certificate {certificateId}"); return true; } catch (Amazon.IoT.Model.ResourceNotFoundException ex) { _logger.LogError($"Cannot delete certificate - resource not found: {ex.Message}"); return false; } catch (Exception ex) { _logger.LogError($"Couldn't delete certificate. Here's why: {ex.Message}"); return false; } }-
API 세부 정보는 AWS SDK for .NET API 참조의 DeleteCertificate를 참조하세요.
-
- C++
-
- SDK for C++
-
참고
GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리
에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요. //! Delete a certificate. /*! \param certificateID: The ID of a certificate. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::IoT::deleteCertificate(const Aws::String &certificateID, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::IoT::IoTClient iotClient(clientConfiguration); Aws::IoT::Model::DeleteCertificateRequest request; request.SetCertificateId(certificateID); Aws::IoT::Model::DeleteCertificateOutcome outcome = iotClient.DeleteCertificate( request); if (outcome.IsSuccess()) { std::cout << "Successfully deleted certificate " << certificateID << std::endl; } else { std::cerr << "Error deleting certificate " << certificateID << ": " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }-
API 세부 정보는 AWS SDK for C++ API 참조의 DeleteCertificate를 참조하세요.
-
- CLI
-
- AWS CLI
-
디바이스 인증서를 삭제하려면
다음
delete-certificate예시에서는 지정된 ID로 디바이스 인증서를 삭제합니다.aws iot delete-certificate \ --certificate-idc0c57bbc8baaf4631a9a0345c957657f5e710473e3ddbee1428d216d54d53ac9이 명령은 출력을 생성하지 않습니다.
자세한 내용은 AWS IoT API 참조의 DeleteCertificate를 참조하세요.
-
API 세부 정보는 AWS CLI 명령 참조의 DeleteCertificate
를 참조하세요.
-
- Java
-
- SDK for Java 2.x
-
참고
GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리
에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요. /** * Deletes a certificate asynchronously. * * @param certificateArn The ARN of the certificate to delete. * * This method initiates an asynchronous request to delete a certificate. * If the deletion is successful, it prints a confirmation message. * If an exception occurs, it prints the error message. */ public void deleteCertificate(String certificateArn) { DeleteCertificateRequest certificateProviderRequest = DeleteCertificateRequest.builder() .certificateId(extractCertificateId(certificateArn)) .build(); CompletableFuture<DeleteCertificateResponse> future = getAsyncClient().deleteCertificate(certificateProviderRequest); future.whenComplete((voidResult, ex) -> { if (ex == null) { System.out.println(certificateArn + " was successfully deleted."); } else { Throwable cause = ex.getCause(); if (cause instanceof IotException) { System.err.println(((IotException) cause).awsErrorDetails().errorMessage()); } else { System.err.println("Unexpected error: " + ex.getMessage()); } } }); future.join(); }-
API 세부 정보는 AWS SDK for Java 2.x API 참조의 DeleteCertificate를 참조하세요.
-
- Kotlin
-
- SDK for Kotlin
-
참고
GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리
에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요. suspend fun deleteCertificate(certificateArn: String) { val certificateProviderRequest = DeleteCertificateRequest { certificateId = extractCertificateId(certificateArn) } IotClient.fromEnvironment { region = "us-east-1" }.use { iotClient -> iotClient.deleteCertificate(certificateProviderRequest) println("$certificateArn was successfully deleted.") } }-
API 세부 정보는 AWS SDK for Kotlin API 참조의 DeleteCertificate
를 참조하세요.
-
- Python
-
- SDK for Python(Boto3)
-
참고
GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리
에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요. class IoTWrapper: """Encapsulates AWS IoT actions.""" def __init__(self, iot_client, iot_data_client=None): """ :param iot_client: A Boto3 AWS IoT client. :param iot_data_client: A Boto3 AWS IoT Data Plane client. """ self.iot_client = iot_client self.iot_data_client = iot_data_client @classmethod def from_client(cls): iot_client = boto3.client("iot") iot_data_client = boto3.client("iot-data") return cls(iot_client, iot_data_client) def delete_certificate(self, certificate_id): """ Deletes an AWS IoT certificate. :param certificate_id: The ID of the certificate to delete. """ try: self.iot_client.update_certificate( certificateId=certificate_id, newStatus="INACTIVE" ) self.iot_client.delete_certificate(certificateId=certificate_id) logger.info("Deleted certificate %s.", certificate_id) except ClientError as err: if err.response["Error"]["Code"] == "ResourceNotFoundException": logger.error("Cannot delete certificate. Resource not found.") return logger.error( "Couldn't delete certificate. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise-
API 세부 정보는 AWS SDK for Python (Boto3) API 참조의 DeleteCertificate를 참조하세요.
-
AWS SDK 개발자 안내서 및 코드 예제의 전체 목록은 섹션을 참조하세요AWS SDK AWS IoT 에서 사용. 이 주제에는 시작하기에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.