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