From 340fbadfd4bb2bdae77813b7a30dc326ad05c20b Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Thu, 9 Apr 2020 10:36:36 -0700 Subject: [PATCH 1/2] fix: use `crytpo_key_path` instead of `crypto_key_path_path` `crypto_key_path_path` was added in error and will be removed in a future version of the library --- kms/api-client/snippets.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kms/api-client/snippets.py b/kms/api-client/snippets.py index d4209e6b18f..6cfd79e9d23 100644 --- a/kms/api-client/snippets.py +++ b/kms/api-client/snippets.py @@ -74,7 +74,7 @@ def encrypt_symmetric(project_id, location_id, key_ring_id, crypto_key_id, client = kms_v1.KeyManagementServiceClient() # The resource name of the CryptoKey. - name = client.crypto_key_path_path(project_id, location_id, key_ring_id, + name = client.crypto_key_path(project_id, location_id, key_ring_id, crypto_key_id) # Use the KMS API to encrypt the data. @@ -94,7 +94,7 @@ def decrypt_symmetric(project_id, location_id, key_ring_id, crypto_key_id, client = kms_v1.KeyManagementServiceClient() # The resource name of the CryptoKey. - name = client.crypto_key_path_path(project_id, location_id, key_ring_id, + name = client.crypto_key_path(project_id, location_id, key_ring_id, crypto_key_id) # Use the KMS API to decrypt the data. response = client.decrypt(name, ciphertext) @@ -219,7 +219,7 @@ def add_member_to_crypto_key_policy( client = kms_v1.KeyManagementServiceClient() # The resource name of the CryptoKey. - resource = client.crypto_key_path_path(project_id, location_id, + resource = client.crypto_key_path(project_id, location_id, key_ring_id, crypto_key_id) # Get the current IAM policy. policy = client.get_iam_policy(resource) @@ -282,7 +282,7 @@ def remove_member_from_crypto_key_policy( client = kms_v1.KeyManagementServiceClient() # The resource name of the CryptoKey. - resource = client.crypto_key_path_path(project_id, location_id, + resource = client.crypto_key_path(project_id, location_id, key_ring_id, crypto_key_id) # Get the current IAM policy. policy = client.get_iam_policy(resource) From a71df4aa54f980cb9a1e3e70a493189e0c3cde15 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Thu, 9 Apr 2020 17:56:13 +0000 Subject: [PATCH 2/2] chore: fix lint --- kms/api-client/snippets.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/kms/api-client/snippets.py b/kms/api-client/snippets.py index 6cfd79e9d23..e09a3a799ac 100644 --- a/kms/api-client/snippets.py +++ b/kms/api-client/snippets.py @@ -74,8 +74,7 @@ def encrypt_symmetric(project_id, location_id, key_ring_id, crypto_key_id, client = kms_v1.KeyManagementServiceClient() # The resource name of the CryptoKey. - name = client.crypto_key_path(project_id, location_id, key_ring_id, - crypto_key_id) + name = client.crypto_key_path(project_id, location_id, key_ring_id, crypto_key_id) # Use the KMS API to encrypt the data. response = client.encrypt(name, plaintext) @@ -94,8 +93,7 @@ def decrypt_symmetric(project_id, location_id, key_ring_id, crypto_key_id, client = kms_v1.KeyManagementServiceClient() # The resource name of the CryptoKey. - name = client.crypto_key_path(project_id, location_id, key_ring_id, - crypto_key_id) + name = client.crypto_key_path(project_id, location_id, key_ring_id, crypto_key_id) # Use the KMS API to decrypt the data. response = client.decrypt(name, ciphertext) return response.plaintext @@ -219,8 +217,7 @@ def add_member_to_crypto_key_policy( client = kms_v1.KeyManagementServiceClient() # The resource name of the CryptoKey. - resource = client.crypto_key_path(project_id, location_id, - key_ring_id, crypto_key_id) + resource = client.crypto_key_path(project_id, location_id, key_ring_id, crypto_key_id) # Get the current IAM policy. policy = client.get_iam_policy(resource) @@ -282,8 +279,8 @@ def remove_member_from_crypto_key_policy( client = kms_v1.KeyManagementServiceClient() # The resource name of the CryptoKey. - resource = client.crypto_key_path(project_id, location_id, - key_ring_id, crypto_key_id) + resource = client.crypto_key_path(project_id, location_id, key_ring_id, crypto_key_id) + # Get the current IAM policy. policy = client.get_iam_policy(resource) @@ -365,8 +362,7 @@ def get_crypto_key_policy(project_id, location_id, key_ring_id, crypto_key_id): client = kms_v1.KeyManagementServiceClient() # The resource name of the CryptoKey. - resource = client.crypto_key_path_path(project_id, location_id, - key_ring_id, crypto_key_id) + resource = client.crypto_key_path(project_id, location_id, key_ring_id, crypto_key_id) # Get the current IAM policy. policy = client.get_iam_policy(resource)