Search in sources :

Example 1 with RestoreCryptoKeyVersionRequest

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

the class Snippets method restoreCryptoKeyVersion.

// [END kms_destroy_cryptokey_version]
// [START kms_restore_cryptokey_version]
/**
 * Restores the given version of a crypto key that is currently scheduled for destruction.
 */
public static CryptoKeyVersion restoreCryptoKeyVersion(String projectId, String locationId, String keyRingId, String cryptoKeyId, String version) throws IOException {
    // Create the Cloud KMS client.
    CloudKMS kms = createAuthorizedClient();
    // The resource name of the cryptoKey version
    String cryptoKeyVersion = String.format("projects/%s/locations/%s/keyRings/%s/cryptoKeys/%s/cryptoKeyVersions/%s", projectId, locationId, keyRingId, cryptoKeyId, version);
    RestoreCryptoKeyVersionRequest restoreRequest = new RestoreCryptoKeyVersionRequest();
    CryptoKeyVersion restored = kms.projects().locations().keyRings().cryptoKeys().cryptoKeyVersions().restore(cryptoKeyVersion, restoreRequest).execute();
    System.out.println(restored);
    return restored;
}
Also used : CloudKMS(com.google.api.services.cloudkms.v1.CloudKMS) RestoreCryptoKeyVersionRequest(com.google.api.services.cloudkms.v1.model.RestoreCryptoKeyVersionRequest) 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 RestoreCryptoKeyVersionRequest (com.google.api.services.cloudkms.v1.model.RestoreCryptoKeyVersionRequest)1