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);
}
Aggregations