Search in sources :

Example 6 with CryptoKeyVersion

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

the class Snippets method enableCryptoKeyVersion.

// [END kms_disable_cryptokey_version]
// [START kms_enable_cryptokey_version]
/**
 * Enables the given version of the crypto key.
 */
public static CryptoKeyVersion enableCryptoKeyVersion(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);
    CryptoKeyVersion newVersionState = new CryptoKeyVersion().setState("ENABLED");
    CryptoKeyVersion response = kms.projects().locations().keyRings().cryptoKeys().cryptoKeyVersions().patch(cryptoKeyVersion, newVersionState).setUpdateMask("state").execute();
    System.out.println(response);
    return response;
}
Also used : CloudKMS(com.google.api.services.cloudkms.v1.CloudKMS) CryptoKeyVersion(com.google.api.services.cloudkms.v1.model.CryptoKeyVersion)

Aggregations

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