Menu
AWS Certificate Manager Private Certificate Authority
User Guide (Version latest)

ListTags

The following Java sample shows how to use the ListTags function.

This function lists the tags, if any, that are associated with your private CA. Tags are labels that you can use to identify and organize your CAs. Each tag consists of a key and an optional value. Call the TagCertificateAuthority function to add one or more tags to your CA. Call the UntagCertificateAuthority function to remove tags.

package com.amazonaws.samples; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.profile.ProfileCredentialsProvider; import com.amazonaws.client.builder.AwsClientBuilder; import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration; import com.amazonaws.AmazonClientException; import com.amazonaws.auth.AWSStaticCredentialsProvider; import com.amazonaws.services.privateca.AWSPrivateCA; import com.amazonaws.services.privateca.AWSPrivateCAClientBuilder; import com.amazonaws.services.privateca.model.ListTagsRequest; import com.amazonaws.services.privateca.model.ListTagsResult; import com.amazonaws.services.privateca.model.ResourceNotFoundException; import com.amazonaws.services.privateca.model.InvalidArnException; import com.amazonaws.services.privateca.model.InvalidTagException; import com.amazonaws.services.privateca.model.TooManyTagsException; public class ListTags { public static void main(String[] args) { // 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("default").getCredentials(); } catch (Exception e) { throw new AmazonClientException("Cannot load your credentials from disk", e); } // Define the endpoint for your sample. String endpointProtocol = "https://acm-pca.region.amazonaws.com/"; String endpointRegion = "region"; EndpointConfiguration endpoint = new AwsClientBuilder.EndpointConfiguration(endpointProtocol, endpointRegion); // Create a client that you can use to make requests. AWSPrivateCA client = AWSPrivateCAClientBuilder.standard() .withEndpointConfiguration(endpoint) .withCredentials(new AWSStaticCredentialsProvider(credentials)) .build(); // Create a request object. ListTagsRequest req = new ListTagsRequest(); req.setCertificateAuthorityArn("arn:aws:acm-pca:region:account:" + "certificate-authority/12345678-1234-1234-1234-123456789012"); // List the tags ListTagsResult result = null; try { result = client.listTags(req); } catch (InvalidArnException ex) { throw ex; } catch(ResourceNotFoundException ex) { throw ex; } catch (InvalidTagException ex) { throw ex; } catch (TooManyTagsException ex) { throw ex; } // Retrieve and display the tags. System.out.println(result); } }

Your output should be similar to the following if you have any tags to list.

{Tags: [{Key: Admin,Value: Alice}, {Key: Purpose,Value: WebServices}],}