Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions kms/api-client/snippets.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -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_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)
Expand All@@ -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_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
Expand DownExpand Up@@ -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_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)

Expand DownExpand Up@@ -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_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)

Expand DownExpand Up@@ -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)
Expand Down