AWS 文檔 AWS SDK示例 GitHub 回購中有更多SDK示例
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
搭RemoveTagsFromCertificate
配 AWS SDK或使用 CLI
下列程式碼範例會示範如何使用RemoveTagsFromCertificate
。
動作範例是大型程式的程式碼摘錄,必須在內容中執行。您可以在下列程式碼範例的內容中看到此動作:
- C++
-
- SDK對於 C ++
-
注意
還有更多關於 GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Remove a tag from an ACM certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param tagKey: The key for the tag. \param tagValue: The value for the tag. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::removeTagsFromCertificate(const Aws::String &certificateArn, const Aws::String &tagKey, const Aws::String &tagValue, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::Vector<Aws::ACM::Model::Tag> tags; Aws::ACM::Model::Tag tag; tag.SetKey(tagKey); tags.push_back(tag); Aws::ACM::Model::RemoveTagsFromCertificateRequest request; request.WithCertificateArn(certificateArn) .WithTags(tags); Aws::ACM::Model::RemoveTagsFromCertificateOutcome outcome = acmClient.RemoveTagsFromCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: RemoveTagFromCertificate: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: Tag with key '" << tagKey << "' removed from " << "certificate with ARN '" << certificateArn << "'." << std::endl; return true; } }
-
如需詳API細資訊,請參閱AWS SDK for C++ API參考RemoveTagsFromCertificate中的。
-
- CLI
-
- AWS CLI
-
若要從憑ACM證移除標籤
下列
remove-tags-from-certificate
命令會從指定的憑證移除兩個標籤。使用空格來分隔多個標籤:aws acm remove-tags-from-certificate --certificate-arn
arn:aws:acm:region:account:certificate/12345678-1234-1234-1234-123456789012
--tagsKey=Admin,Value=Alice
Key=Purpose,Value=Website
-
如需詳API細資訊,請參閱AWS CLI 指令參考RemoveTagsFromCertificate
中的。
-
- Python
-
- SDK對於 Python(肉毒桿菌 3)
-
注意
還有更多關於 GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 class AcmCertificate: """ Encapsulates ACM functions. """ def __init__(self, acm_client): """ :param acm_client: A Boto3 ACM client. """ self.acm_client = acm_client def remove_tags(self, certificate_arn, tags): """ Removes tags from a certificate. If the value of a tag is specified, the tag is removed only when the value matches the value of the certificate's tag. Otherwise, the tag is removed regardless of its value. :param certificate_arn: The ARN of the certificate. :param tags: The dictionary of tags to remove. """ try: cert_tags = [] for key, value in tags.items(): tag = {"Key": key} if value is not None: tag["Value"] = value cert_tags.append(tag) self.acm_client.remove_tags_from_certificate( CertificateArn=certificate_arn, Tags=cert_tags ) logger.info( "Removed %s tags from certificate %s.", len(tags), certificate_arn ) except ClientError: logger.exception( "Couldn't remove tags from certificate %s.", certificate_arn ) raise
-
如需詳API細資訊,請參閱RemoveTagsFromCertificate中AWS SDK的〈〉以取得 Python (Boto3) API 參考資料。
-
ListTagsForCertificate
RenewCertificate