从证书中删除标签 - Amazon 证书 Manager
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

从证书中删除标签

以下示例说明如何使用 RemoveTagsFromCertificate 函数。

package com.amazonaws.samples; import com.amazonaws.services.certificatemanager.AWSCertificateManagerClientBuilder; import com.amazonaws.services.certificatemanager.AWSCertificateManager; import com.amazonaws.services.certificatemanager.model.RemoveTagsFromCertificateRequest; import com.amazonaws.services.certificatemanager.model.RemoveTagsFromCertificateResult; import com.amazonaws.services.certificatemanager.model.Tag; import com.amazonaws.services.certificatemanager.model.InvalidArnException; import com.amazonaws.services.certificatemanager.model.InvalidTagException; import com.amazonaws.services.certificatemanager.model.ResourceNotFoundException; import com.amazonaws.AmazonClientException; import com.amazonaws.auth.profile.ProfileCredentialsProvider; import com.amazonaws.auth.AWSStaticCredentialsProvider; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.regions.Regions; import java.util.ArrayList; /** * This sample demonstrates how to use the RemoveTagsFromCertificate function in the Amazon Certificate * Manager service. * * Input parameters: * CertificateArn - The ARN of the certificate from which you want to remove one or more tags. * Tags - A collection of key-value pairs that specify which tags to remove. * */ public class AWSCertificateManagerExample { public static void main(String[] args) throws Exception { // Retrieve your credentials from the C:\Users\name\.aws\credentials file in Windows // or the ~/.aws/credentials file in Linux. AWSCredentials credentials = null; try { credentials = new ProfileCredentialsProvider().getCredentials(); } catch (Exception ex) { throw new AmazonClientException("Cannot load your credentials from file.", ex); } // Create a client. AWSCertificateManager client = AWSCertificateManagerClientBuilder.standard() .withRegion(Regions.US_EAST_1) .withCredentials(new AWSStaticCredentialsProvider(credentials)) .build(); // Specify the tags to remove. Tag tag1 = new Tag(); tag1.setKey("Short_Name"); tag1.setValue("My_Cert"); Tag tag2 = new Tag() .withKey("Purpose") .withValue("Test"); // Add the tags to a collection. ArrayList<Tag> tags = new ArrayList<Tag>(); tags.add(tag1); tags.add(tag2); // Create a request object. RemoveTagsFromCertificateRequest req = new RemoveTagsFromCertificateRequest(); req.setCertificateArn("arn:aws:acm:region:account:certificate/12345678-1234-1234-1234-123456789012"); req.setTags(tags); // Create a result object. RemoveTagsFromCertificateResult result = null; try { result = client.removeTagsFromCertificate(req); } catch(InvalidArnException ex) { throw ex; } catch(InvalidTagException ex) { throw ex; } catch(ResourceNotFoundException ex) { throw ex; } // Display the result. System.out.println(result); } }