diff --git a/kms/snippets/create_key_asymmetric_decrypt.py b/kms/snippets/create_key_asymmetric_decrypt.py index 993d6840a2df..5d0e64a0754e 100644 --- a/kms/snippets/create_key_asymmetric_decrypt.py +++ b/kms/snippets/create_key_asymmetric_decrypt.py @@ -13,7 +13,7 @@ # [START kms_create_key_asymmetric_decrypt] -def create_key_asymmetric_decrypt(project_id, location_id, key_ring_id, id): +def create_key_asymmetric_decrypt(project_id, location_id, key_ring_id, key_id): """ Creates a new asymmetric decryption key in Cloud KMS. @@ -21,7 +21,7 @@ def create_key_asymmetric_decrypt(project_id, location_id, key_ring_id, id): project_id (string): Google Cloud project ID (e.g. 'my-project'). location_id (string): Cloud KMS location (e.g. 'us-east1'). key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring'). - id (string): ID of the key to create (e.g. 'my-asymmetric-decrypt-key'). + key_id (string): ID of the key to create (e.g. 'my-asymmetric-decrypt-key'). Returns: CryptoKey: Cloud KMS key. @@ -54,7 +54,8 @@ def create_key_asymmetric_decrypt(project_id, location_id, key_ring_id, id): } # Call the API. - created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key}) + created_key = client.create_crypto_key( + request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key}) print('Created asymmetric decrypt key: {}'.format(created_key.name)) return created_key # [END kms_create_key_asymmetric_decrypt] diff --git a/kms/snippets/create_key_asymmetric_sign.py b/kms/snippets/create_key_asymmetric_sign.py index b3fbaa9e2fd2..0422508ceb21 100644 --- a/kms/snippets/create_key_asymmetric_sign.py +++ b/kms/snippets/create_key_asymmetric_sign.py @@ -13,7 +13,7 @@ # [START kms_create_key_asymmetric_sign] -def create_key_asymmetric_sign(project_id, location_id, key_ring_id, id): +def create_key_asymmetric_sign(project_id, location_id, key_ring_id, key_id): """ Creates a new asymmetric signing key in Cloud KMS. @@ -21,7 +21,7 @@ def create_key_asymmetric_sign(project_id, location_id, key_ring_id, id): project_id (string): Google Cloud project ID (e.g. 'my-project'). location_id (string): Cloud KMS location (e.g. 'us-east1'). key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring'). - id (string): ID of the key to create (e.g. 'my-asymmetric-signing-key'). + key_id (string): ID of the key to create (e.g. 'my-asymmetric-signing-key'). Returns: CryptoKey: Cloud KMS key. @@ -54,7 +54,8 @@ def create_key_asymmetric_sign(project_id, location_id, key_ring_id, id): } # Call the API. - created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key}) + created_key = client.create_crypto_key( + request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key}) print('Created asymmetric signing key: {}'.format(created_key.name)) return created_key # [END kms_create_key_asymmetric_sign] diff --git a/kms/snippets/create_key_hsm.py b/kms/snippets/create_key_hsm.py index a850391a3eb7..6e95e68c9275 100644 --- a/kms/snippets/create_key_hsm.py +++ b/kms/snippets/create_key_hsm.py @@ -13,7 +13,7 @@ # [START kms_create_key_hsm] -def create_key_hsm(project_id, location_id, key_ring_id, id): +def create_key_hsm(project_id, location_id, key_ring_id, key_id): """ Creates a new key in Cloud KMS backed by Cloud HSM. @@ -21,7 +21,7 @@ def create_key_hsm(project_id, location_id, key_ring_id, id): project_id (string): Google Cloud project ID (e.g. 'my-project'). location_id (string): Cloud KMS location (e.g. 'us-east1'). key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring'). - id (string): ID of the key to create (e.g. 'my-hsm-key'). + key_id (string): ID of the key to create (e.g. 'my-hsm-key'). Returns: CryptoKey: Cloud KMS key. @@ -56,7 +56,8 @@ def create_key_hsm(project_id, location_id, key_ring_id, id): } # Call the API. - created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key}) + created_key = client.create_crypto_key( + request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key}) print('Created hsm key: {}'.format(created_key.name)) return created_key # [END kms_create_key_hsm] diff --git a/kms/snippets/create_key_labels.py b/kms/snippets/create_key_labels.py index 1bef62ebfb24..cf84265a704e 100644 --- a/kms/snippets/create_key_labels.py +++ b/kms/snippets/create_key_labels.py @@ -13,7 +13,7 @@ # [START kms_create_key_labels] -def create_key_labels(project_id, location_id, key_ring_id, id): +def create_key_labels(project_id, location_id, key_ring_id, key_id): """ Creates a new key in Cloud KMS with labels. @@ -21,7 +21,7 @@ def create_key_labels(project_id, location_id, key_ring_id, id): project_id (string): Google Cloud project ID (e.g. 'my-project'). location_id (string): Cloud KMS location (e.g. 'us-east1'). key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring'). - id (string): ID of the key to create (e.g. 'my-labeled-key'). + key_id (string): ID of the key to create (e.g. 'my-labeled-key'). Returns: CryptoKey: Cloud KMS key. @@ -52,7 +52,8 @@ def create_key_labels(project_id, location_id, key_ring_id, id): } # Call the API. - created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key}) + created_key = client.create_crypto_key( + request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key}) print('Created labeled key: {}'.format(created_key.name)) return created_key # [END kms_create_key_labels] diff --git a/kms/snippets/create_key_mac.py b/kms/snippets/create_key_mac.py index db8d086eded6..7c4c86755843 100644 --- a/kms/snippets/create_key_mac.py +++ b/kms/snippets/create_key_mac.py @@ -13,7 +13,7 @@ # [START kms_create_key_mac] -def create_key_mac(project_id, location_id, key_ring_id, id): +def create_key_mac(project_id, location_id, key_ring_id, key_id): """ Creates a new key in Cloud KMS for HMAC operations. @@ -21,7 +21,7 @@ def create_key_mac(project_id, location_id, key_ring_id, id): project_id (string): Google Cloud project ID (e.g. 'my-project'). location_id (string): Cloud KMS location (e.g. 'us-east1'). key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring'). - id (string): ID of the key to create (e.g. 'my-mac-key'). + key_id (string): ID of the key to create (e.g. 'my-mac-key'). Returns: CryptoKey: Cloud KMS key. @@ -54,7 +54,8 @@ def create_key_mac(project_id, location_id, key_ring_id, id): } # Call the API. - created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key}) + created_key = client.create_crypto_key( + request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key}) print('Created mac key: {}'.format(created_key.name)) return created_key # [END kms_create_key_mac] diff --git a/kms/snippets/create_key_ring.py b/kms/snippets/create_key_ring.py index 49348aa9a20d..89e914e54268 100644 --- a/kms/snippets/create_key_ring.py +++ b/kms/snippets/create_key_ring.py @@ -13,14 +13,14 @@ # [START kms_create_key_ring] -def create_key_ring(project_id, location_id, id): +def create_key_ring(project_id, location_id, key_ring_id): """ Creates a new key ring in Cloud KMS Args: project_id (string): Google Cloud project ID (e.g. 'my-project'). location_id (string): Cloud KMS location (e.g. 'us-east1'). - id (string): ID of the key ring to create (e.g. 'my-key-ring'). + key_ring_id (string): ID of the key ring to create (e.g. 'my-key-ring'). Returns: KeyRing: Cloud KMS key ring. @@ -40,7 +40,8 @@ def create_key_ring(project_id, location_id, id): key_ring = {} # Call the API. - created_key_ring = client.create_key_ring(request={'parent': location_name, 'key_ring_id': id, 'key_ring': key_ring}) + created_key_ring = client.create_key_ring( + request={'parent': location_name, 'key_ring_id': key_ring_id, 'key_ring': key_ring}) print('Created key ring: {}'.format(created_key_ring.name)) return created_key_ring # [END kms_create_key_ring] diff --git a/kms/snippets/create_key_rotation_schedule.py b/kms/snippets/create_key_rotation_schedule.py index 02e323345e6f..ce450dea8334 100644 --- a/kms/snippets/create_key_rotation_schedule.py +++ b/kms/snippets/create_key_rotation_schedule.py @@ -13,7 +13,7 @@ # [START kms_create_key_rotation_schedule] -def create_key_rotation_schedule(project_id, location_id, key_ring_id, id): +def create_key_rotation_schedule(project_id, location_id, key_ring_id, key_id): """ Creates a new key in Cloud KMS that automatically rotates. @@ -21,7 +21,7 @@ def create_key_rotation_schedule(project_id, location_id, key_ring_id, id): project_id (string): Google Cloud project ID (e.g. 'my-project'). location_id (string): Cloud KMS location (e.g. 'us-east1'). key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring'). - id (string): ID of the key to create (e.g. 'my-rotating-key'). + key_id (string): ID of the key to create (e.g. 'my-rotating-key'). Returns: CryptoKey: Cloud KMS key. @@ -51,17 +51,18 @@ def create_key_rotation_schedule(project_id, location_id, key_ring_id, id): # Rotate the key every 30 days. 'rotation_period': { - 'seconds': 60*60*24*30 + 'seconds': 60 * 60 * 24 * 30 }, # Start the first rotation in 24 hours. 'next_rotation_time': { - 'seconds': int(time.time()) + 60*60*24 + 'seconds': int(time.time()) + 60 * 60 * 24 } } # Call the API. - created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key}) + created_key = client.create_crypto_key( + request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key}) print('Created labeled key: {}'.format(created_key.name)) return created_key # [END kms_create_key_rotation_schedule] diff --git a/kms/snippets/create_key_symmetric_encrypt_decrypt.py b/kms/snippets/create_key_symmetric_encrypt_decrypt.py index 1b6b88c5cf50..abc4eae2b787 100644 --- a/kms/snippets/create_key_symmetric_encrypt_decrypt.py +++ b/kms/snippets/create_key_symmetric_encrypt_decrypt.py @@ -13,7 +13,7 @@ # [START kms_create_key_symmetric_encrypt_decrypt] -def create_key_symmetric_encrypt_decrypt(project_id, location_id, key_ring_id, id): +def create_key_symmetric_encrypt_decrypt(project_id, location_id, key_ring_id, key_id): """ Creates a new symmetric encryption/decryption key in Cloud KMS. @@ -21,7 +21,7 @@ def create_key_symmetric_encrypt_decrypt(project_id, location_id, key_ring_id, i project_id (string): Google Cloud project ID (e.g. 'my-project'). location_id (string): Cloud KMS location (e.g. 'us-east1'). key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring'). - id (string): ID of the key to create (e.g. 'my-symmetric-key'). + key_id (string): ID of the key to create (e.g. 'my-symmetric-key'). Returns: CryptoKey: Cloud KMS key. @@ -43,12 +43,13 @@ def create_key_symmetric_encrypt_decrypt(project_id, location_id, key_ring_id, i key = { 'purpose': purpose, 'version_template': { - 'algorithm': algorithm, + 'algorithm': algorithm, } } # Call the API. - created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key}) + created_key = client.create_crypto_key( + request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key}) print('Created symmetric key: {}'.format(created_key.name)) return created_key # [END kms_create_key_symmetric_encrypt_decrypt]