Search in sources :

Example 1 with ListCryptoKeyVersionsResponse

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);
    }
}
Also used : CloudKMS(com.google.api.services.cloudkms.v1.CloudKMS) ListCryptoKeyVersionsResponse(com.google.api.services.cloudkms.v1.model.ListCryptoKeyVersionsResponse) CryptoKeyVersion(com.google.api.services.cloudkms.v1.model.CryptoKeyVersion)

Aggregations

CloudKMS (com.google.api.services.cloudkms.v1.CloudKMS)1 CryptoKeyVersion (com.google.api.services.cloudkms.v1.model.CryptoKeyVersion)1 ListCryptoKeyVersionsResponse (com.google.api.services.cloudkms.v1.model.ListCryptoKeyVersionsResponse)1