Search in sources :

Example 1 with ListCryptoKeysResponse

use of com.google.api.services.cloudkms.v1.model.ListCryptoKeysResponse in project java-docs-samples by GoogleCloudPlatform.

the class Snippets method listCryptoKeys.

/**
 * Prints all crypto keys in the given key ring.
 */
public static void listCryptoKeys(String projectId, String locationId, String keyRingId) throws IOException {
    // Create the Cloud KMS client.
    CloudKMS kms = createAuthorizedClient();
    // The resource name of the cryptoKey
    String keyRingPath = String.format("projects/%s/locations/%s/keyRings/%s", projectId, locationId, keyRingId);
    ListCryptoKeysResponse cryptoKeys = null;
    do {
        // Print every page of keys
        cryptoKeys = kms.projects().locations().keyRings().cryptoKeys().list(keyRingPath).setPageToken(cryptoKeys != null ? cryptoKeys.getNextPageToken() : null).execute();
        for (CryptoKey key : cryptoKeys.getCryptoKeys()) {
            System.out.println(key);
        }
    } while (cryptoKeys.getNextPageToken() != null);
}
Also used : ListCryptoKeysResponse(com.google.api.services.cloudkms.v1.model.ListCryptoKeysResponse) CloudKMS(com.google.api.services.cloudkms.v1.CloudKMS) CryptoKey(com.google.api.services.cloudkms.v1.model.CryptoKey)

Aggregations

CloudKMS (com.google.api.services.cloudkms.v1.CloudKMS)1 CryptoKey (com.google.api.services.cloudkms.v1.model.CryptoKey)1 ListCryptoKeysResponse (com.google.api.services.cloudkms.v1.model.ListCryptoKeysResponse)1