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