diff --git a/kms/src/main/java/com/example/CryptFile.java b/kms/src/main/java/com/example/CryptFile.java index 4a97bd7a903..26e39152ff6 100644 --- a/kms/src/main/java/com/example/CryptFile.java +++ b/kms/src/main/java/com/example/CryptFile.java @@ -16,7 +16,7 @@ package com.example; -import com.google.cloud.kms.v1.CryptoKeyName; +import com.google.cloud.kms.v1.CryptoKeyPathName; import com.google.cloud.kms.v1.DecryptResponse; import com.google.cloud.kms.v1.EncryptResponse; import com.google.cloud.kms.v1.KeyManagementServiceClient; @@ -41,7 +41,7 @@ public static byte[] encrypt( try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) { // The resource name of the cryptoKey - String resourceName = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId); + String resourceName = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId); // Encrypt the plaintext with Cloud KMS. EncryptResponse response = client.encrypt(resourceName, ByteString.copyFrom(plaintext)); @@ -65,7 +65,7 @@ public static byte[] decrypt( try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) { // The resource name of the cryptoKey - String resourceName = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId); + String resourceName = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId); // Decrypt the ciphertext with Cloud KMS. DecryptResponse response = client.decrypt(resourceName, ByteString.copyFrom(ciphertext)); diff --git a/kms/src/main/java/com/example/Snippets.java b/kms/src/main/java/com/example/Snippets.java index 30f6f2875bf..7499fa25a5d 100644 --- a/kms/src/main/java/com/example/Snippets.java +++ b/kms/src/main/java/com/example/Snippets.java @@ -18,7 +18,7 @@ import com.google.cloud.kms.v1.CryptoKey; import com.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose; -import com.google.cloud.kms.v1.CryptoKeyName; +import com.google.cloud.kms.v1.CryptoKeyPathName; import com.google.cloud.kms.v1.CryptoKeyVersion; import com.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState; import com.google.cloud.kms.v1.CryptoKeyVersionName; @@ -103,7 +103,7 @@ public static CryptoKeyVersion createCryptoKeyVersion( try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) { // The resource name of the cryptoKey - String cryptoKey = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId); + String cryptoKey = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId); CryptoKeyVersion version = CryptoKeyVersion.newBuilder().build(); @@ -243,7 +243,7 @@ public static Policy getCryptoKeyPolicy( try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) { // The resource name of the cryptoKey version - String keyName = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId); + String keyName = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId); // Get the current IAM policy and add the new account to it. Policy iamPolicy = client.getIamPolicy(keyName); @@ -302,7 +302,7 @@ public static Policy addMemberToCryptoKeyPolicy( try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) { // The resource name of the cryptoKey version - String keyName = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId); + String keyName = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId); // Get the current IAM policy Policy iamPolicy = client.getIamPolicy(keyName); @@ -392,7 +392,7 @@ public static Policy removeMemberFromCryptoKeyPolicy( try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) { // The resource name of the cryptoKey version - String keyName = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId); + String keyName = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId); // Get the current IAM policy Policy iamPolicy = client.getIamPolicy(keyName); @@ -531,7 +531,7 @@ public static List listCryptoKeyVersions( try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) { // The resource name of the CryptoKey to search. - String parent = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId); + String parent = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId); // Retrieve a paginated list of CryptoKeyVersions ListCryptoKeyVersionsPagedResponse response = client.listCryptoKeyVersions(parent); @@ -557,7 +557,7 @@ public static CryptoKey setPrimaryVersion(String projectId, String locationId, S try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) { // The resource name of the CryptoKey to update. - String resourceName = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId); + String resourceName = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId); // Update the primary CryptoKey version CryptoKey key = client.updateCryptoKeyPrimaryVersion(resourceName, versionId);