Search in sources :

Example 1 with ListServerCertificatesRequest

use of software.amazon.awssdk.services.iam.model.ListServerCertificatesRequest in project aws-doc-sdk-examples by awsdocs.

the class ListServerCertificates method listCertificates.

// snippet-start:[iam.java2.list_server_certificates.main]
public static void listCertificates(IamClient iam) {
    try {
        boolean done = false;
        String newMarker = null;
        while (!done) {
            ListServerCertificatesResponse response;
            if (newMarker == null) {
                ListServerCertificatesRequest request = ListServerCertificatesRequest.builder().build();
                response = iam.listServerCertificates(request);
            } else {
                ListServerCertificatesRequest request = ListServerCertificatesRequest.builder().marker(newMarker).build();
                response = iam.listServerCertificates(request);
            }
            for (ServerCertificateMetadata metadata : response.serverCertificateMetadataList()) {
                System.out.printf("Retrieved server certificate %s", metadata.serverCertificateName());
            }
            if (!response.isTruncated()) {
                done = true;
            } else {
                newMarker = response.marker();
            }
        }
    } catch (IamException e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
}
Also used : ServerCertificateMetadata(software.amazon.awssdk.services.iam.model.ServerCertificateMetadata) ListServerCertificatesResponse(software.amazon.awssdk.services.iam.model.ListServerCertificatesResponse) ListServerCertificatesRequest(software.amazon.awssdk.services.iam.model.ListServerCertificatesRequest) IamException(software.amazon.awssdk.services.iam.model.IamException)

Aggregations

IamException (software.amazon.awssdk.services.iam.model.IamException)1 ListServerCertificatesRequest (software.amazon.awssdk.services.iam.model.ListServerCertificatesRequest)1 ListServerCertificatesResponse (software.amazon.awssdk.services.iam.model.ListServerCertificatesResponse)1 ServerCertificateMetadata (software.amazon.awssdk.services.iam.model.ServerCertificateMetadata)1