Search in sources :

Example 1 with ListGrantsRequest

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

the class ListGrants method displayGrantIds.

// snippet-start:[kms.java2_list_grant.main]
public static void displayGrantIds(KmsClient kmsClient, String keyId) {
    try {
        ListGrantsRequest grantsRequest = ListGrantsRequest.builder().keyId(keyId).limit(15).build();
        ListGrantsResponse response = kmsClient.listGrants(grantsRequest);
        List<GrantListEntry> grants = response.grants();
        for (GrantListEntry grant : grants) {
            System.out.println("The grant Id is : " + grant.grantId());
        }
    } catch (KmsException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
}
Also used : ListGrantsRequest(software.amazon.awssdk.services.kms.model.ListGrantsRequest) ListGrantsResponse(software.amazon.awssdk.services.kms.model.ListGrantsResponse) KmsException(software.amazon.awssdk.services.kms.model.KmsException) GrantListEntry(software.amazon.awssdk.services.kms.model.GrantListEntry)

Aggregations

GrantListEntry (software.amazon.awssdk.services.kms.model.GrantListEntry)1 KmsException (software.amazon.awssdk.services.kms.model.KmsException)1 ListGrantsRequest (software.amazon.awssdk.services.kms.model.ListGrantsRequest)1 ListGrantsResponse (software.amazon.awssdk.services.kms.model.ListGrantsResponse)1