Utilizzare RemoveTagsFromCertificate con un o AWS SDK CLI - Esempi di codice dell'AWS SDK

Ci sono altri AWS SDK esempi disponibili nel repository AWS Doc SDK Examples GitHub .

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Utilizzare RemoveTagsFromCertificate con un o AWS SDK CLI

I seguenti esempi di codice mostrano come utilizzareRemoveTagsFromCertificate.

Gli esempi di operazioni sono estratti di codice da programmi più grandi e devono essere eseguiti nel contesto. È possibile visualizzare questa operazione nel contesto nel seguente esempio di codice:

C++
SDKper C++
Nota

C'è altro su. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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; } }
CLI
AWS CLI

Per rimuovere un tag da un ACM certificato

Il remove-tags-from-certificate comando seguente rimuove due tag dal certificato specificato. Usa uno spazio per separare più tag:

aws acm remove-tags-from-certificate --certificate-arn arn:aws:acm:region:account:certificate/12345678-1234-1234-1234-123456789012 --tags Key=Admin,Value=Alice Key=Purpose,Value=Website
Python
SDKper Python (Boto3)
Nota

C'è di più su. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice 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