Search in sources :

Example 1 with UpdateCryptoKeyPrimaryVersionRequest

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

the class Snippets method setPrimaryVersion.

/**
 * Sets a version as the primary version for a crypto key.
 */
public static void setPrimaryVersion(String projectId, String locationId, String keyRingId, String cryptoKeyId, String versionId) throws IOException {
    // Create the Cloud KMS client.
    CloudKMS kms = createAuthorizedClient();
    // Resource name of the key version.
    String resourceName = String.format("projects/%s/locations/%s/keyRings/%s/cryptoKeys/%s", projectId, locationId, keyRingId, cryptoKeyId);
    CryptoKey key = kms.projects().locations().keyRings().cryptoKeys().updatePrimaryVersion(resourceName, new UpdateCryptoKeyPrimaryVersionRequest().setCryptoKeyVersionId(versionId)).execute();
    System.out.println(key);
}
Also used : CloudKMS(com.google.api.services.cloudkms.v1.CloudKMS) CryptoKey(com.google.api.services.cloudkms.v1.model.CryptoKey) UpdateCryptoKeyPrimaryVersionRequest(com.google.api.services.cloudkms.v1.model.UpdateCryptoKeyPrimaryVersionRequest)

Aggregations

CloudKMS (com.google.api.services.cloudkms.v1.CloudKMS)1 CryptoKey (com.google.api.services.cloudkms.v1.model.CryptoKey)1 UpdateCryptoKeyPrimaryVersionRequest (com.google.api.services.cloudkms.v1.model.UpdateCryptoKeyPrimaryVersionRequest)1