use of com.google.api.services.cloudkms.v1.model.ListCryptoKeyVersionsResponse in project java-docs-samples by GoogleCloudPlatform.
the class Snippets method listCryptoKeyVersions.
/**
* Prints all the versions for the given crypto key.
*/
public static void listCryptoKeyVersions(String projectId, String locationId, String keyRingId, String cryptoKeyId) throws IOException {
// Create the Cloud KMS client.
CloudKMS kms = createAuthorizedClient();
// The resource name of the cryptoKey
String cryptoKeys = String.format("projects/%s/locations/%s/keyRings/%s/cryptoKeys/%s", projectId, locationId, keyRingId, cryptoKeyId);
ListCryptoKeyVersionsResponse versions = kms.projects().locations().keyRings().cryptoKeys().cryptoKeyVersions().list(cryptoKeys).execute();
for (CryptoKeyVersion version : versions.getCryptoKeyVersions()) {
System.out.println(version);
}
}
Aggregations