Search in sources :

Example 1 with DestroyCryptoKeyVersionRequest

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

the class Snippets method destroyCryptoKeyVersion.

// [END kms_enable_cryptokey_version]
// [START kms_destroy_cryptokey_version]
/**
 * Marks the given version of a crypto key to be destroyed at a scheduled future point.
 */
public static CryptoKeyVersion destroyCryptoKeyVersion(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);
    DestroyCryptoKeyVersionRequest destroyRequest = new DestroyCryptoKeyVersionRequest();
    CryptoKeyVersion destroyed = kms.projects().locations().keyRings().cryptoKeys().cryptoKeyVersions().destroy(cryptoKeyVersion, destroyRequest).execute();
    System.out.println(destroyed);
    return destroyed;
}
Also used : CloudKMS(com.google.api.services.cloudkms.v1.CloudKMS) CryptoKeyVersion(com.google.api.services.cloudkms.v1.model.CryptoKeyVersion) DestroyCryptoKeyVersionRequest(com.google.api.services.cloudkms.v1.model.DestroyCryptoKeyVersionRequest)

Aggregations

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