Skip to content

Commit b958c27

Browse files
Sita04rsamborski
authored andcommitted
docs(samples): updated var name to avoid shadowing built-in (#238)
1 parent 6a4b114 commit b958c27

8 files changed

+35
-27
lines changed

kms/snippets/create_key_asymmetric_decrypt.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414

1515
# [START kms_create_key_asymmetric_decrypt]
16-
def create_key_asymmetric_decrypt(project_id, location_id, key_ring_id, id):
16+
def create_key_asymmetric_decrypt(project_id, location_id, key_ring_id, key_id):
1717
"""
1818
Creates a new asymmetric decryption key in Cloud KMS.
1919
2020
Args:
2121
project_id (string): Google Cloud project ID (e.g. 'my-project').
2222
location_id (string): Cloud KMS location (e.g. 'us-east1').
2323
key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring').
24-
id (string): ID of the key to create (e.g. 'my-asymmetric-decrypt-key').
24+
key_id (string): ID of the key to create (e.g. 'my-asymmetric-decrypt-key').
2525
2626
Returns:
2727
CryptoKey: Cloud KMS key.
@@ -54,7 +54,8 @@ def create_key_asymmetric_decrypt(project_id, location_id, key_ring_id, id):
5454
}
5555

5656
# Call the API.
57-
created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key})
57+
created_key = client.create_crypto_key(
58+
request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key})
5859
print('Created asymmetric decrypt key: {}'.format(created_key.name))
5960
return created_key
6061
# [END kms_create_key_asymmetric_decrypt]

kms/snippets/create_key_asymmetric_sign.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414

1515
# [START kms_create_key_asymmetric_sign]
16-
def create_key_asymmetric_sign(project_id, location_id, key_ring_id, id):
16+
def create_key_asymmetric_sign(project_id, location_id, key_ring_id, key_id):
1717
"""
1818
Creates a new asymmetric signing key in Cloud KMS.
1919
2020
Args:
2121
project_id (string): Google Cloud project ID (e.g. 'my-project').
2222
location_id (string): Cloud KMS location (e.g. 'us-east1').
2323
key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring').
24-
id (string): ID of the key to create (e.g. 'my-asymmetric-signing-key').
24+
key_id (string): ID of the key to create (e.g. 'my-asymmetric-signing-key').
2525
2626
Returns:
2727
CryptoKey: Cloud KMS key.
@@ -54,7 +54,8 @@ def create_key_asymmetric_sign(project_id, location_id, key_ring_id, id):
5454
}
5555

5656
# Call the API.
57-
created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key})
57+
created_key = client.create_crypto_key(
58+
request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key})
5859
print('Created asymmetric signing key: {}'.format(created_key.name))
5960
return created_key
6061
# [END kms_create_key_asymmetric_sign]

kms/snippets/create_key_hsm.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414

1515
# [START kms_create_key_hsm]
16-
def create_key_hsm(project_id, location_id, key_ring_id, id):
16+
def create_key_hsm(project_id, location_id, key_ring_id, key_id):
1717
"""
1818
Creates a new key in Cloud KMS backed by Cloud HSM.
1919
2020
Args:
2121
project_id (string): Google Cloud project ID (e.g. 'my-project').
2222
location_id (string): Cloud KMS location (e.g. 'us-east1').
2323
key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring').
24-
id (string): ID of the key to create (e.g. 'my-hsm-key').
24+
key_id (string): ID of the key to create (e.g. 'my-hsm-key').
2525
2626
Returns:
2727
CryptoKey: Cloud KMS key.
@@ -56,7 +56,8 @@ def create_key_hsm(project_id, location_id, key_ring_id, id):
5656
}
5757

5858
# Call the API.
59-
created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key})
59+
created_key = client.create_crypto_key(
60+
request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key})
6061
print('Created hsm key: {}'.format(created_key.name))
6162
return created_key
6263
# [END kms_create_key_hsm]

kms/snippets/create_key_labels.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414

1515
# [START kms_create_key_labels]
16-
def create_key_labels(project_id, location_id, key_ring_id, id):
16+
def create_key_labels(project_id, location_id, key_ring_id, key_id):
1717
"""
1818
Creates a new key in Cloud KMS with labels.
1919
2020
Args:
2121
project_id (string): Google Cloud project ID (e.g. 'my-project').
2222
location_id (string): Cloud KMS location (e.g. 'us-east1').
2323
key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring').
24-
id (string): ID of the key to create (e.g. 'my-labeled-key').
24+
key_id (string): ID of the key to create (e.g. 'my-labeled-key').
2525
2626
Returns:
2727
CryptoKey: Cloud KMS key.
@@ -52,7 +52,8 @@ def create_key_labels(project_id, location_id, key_ring_id, id):
5252
}
5353

5454
# Call the API.
55-
created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key})
55+
created_key = client.create_crypto_key(
56+
request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key})
5657
print('Created labeled key: {}'.format(created_key.name))
5758
return created_key
5859
# [END kms_create_key_labels]

kms/snippets/create_key_mac.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414

1515
# [START kms_create_key_mac]
16-
def create_key_mac(project_id, location_id, key_ring_id, id):
16+
def create_key_mac(project_id, location_id, key_ring_id, key_id):
1717
"""
1818
Creates a new key in Cloud KMS for HMAC operations.
1919
2020
Args:
2121
project_id (string): Google Cloud project ID (e.g. 'my-project').
2222
location_id (string): Cloud KMS location (e.g. 'us-east1').
2323
key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring').
24-
id (string): ID of the key to create (e.g. 'my-mac-key').
24+
key_id (string): ID of the key to create (e.g. 'my-mac-key').
2525
2626
Returns:
2727
CryptoKey: Cloud KMS key.
@@ -54,7 +54,8 @@ def create_key_mac(project_id, location_id, key_ring_id, id):
5454
}
5555

5656
# Call the API.
57-
created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key})
57+
created_key = client.create_crypto_key(
58+
request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key})
5859
print('Created mac key: {}'.format(created_key.name))
5960
return created_key
6061
# [END kms_create_key_mac]

kms/snippets/create_key_ring.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414

1515
# [START kms_create_key_ring]
16-
def create_key_ring(project_id, location_id, id):
16+
def create_key_ring(project_id, location_id, key_ring_id):
1717
"""
1818
Creates a new key ring in Cloud KMS
1919
2020
Args:
2121
project_id (string): Google Cloud project ID (e.g. 'my-project').
2222
location_id (string): Cloud KMS location (e.g. 'us-east1').
23-
id (string): ID of the key ring to create (e.g. 'my-key-ring').
23+
key_ring_id (string): ID of the key ring to create (e.g. 'my-key-ring').
2424
2525
Returns:
2626
KeyRing: Cloud KMS key ring.
@@ -40,7 +40,8 @@ def create_key_ring(project_id, location_id, id):
4040
key_ring = {}
4141

4242
# Call the API.
43-
created_key_ring = client.create_key_ring(request={'parent': location_name, 'key_ring_id': id, 'key_ring': key_ring})
43+
created_key_ring = client.create_key_ring(
44+
request={'parent': location_name, 'key_ring_id': key_ring_id, 'key_ring': key_ring})
4445
print('Created key ring: {}'.format(created_key_ring.name))
4546
return created_key_ring
4647
# [END kms_create_key_ring]

kms/snippets/create_key_rotation_schedule.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414

1515
# [START kms_create_key_rotation_schedule]
16-
def create_key_rotation_schedule(project_id, location_id, key_ring_id, id):
16+
def create_key_rotation_schedule(project_id, location_id, key_ring_id, key_id):
1717
"""
1818
Creates a new key in Cloud KMS that automatically rotates.
1919
2020
Args:
2121
project_id (string): Google Cloud project ID (e.g. 'my-project').
2222
location_id (string): Cloud KMS location (e.g. 'us-east1').
2323
key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring').
24-
id (string): ID of the key to create (e.g. 'my-rotating-key').
24+
key_id (string): ID of the key to create (e.g. 'my-rotating-key').
2525
2626
Returns:
2727
CryptoKey: Cloud KMS key.
@@ -51,17 +51,18 @@ def create_key_rotation_schedule(project_id, location_id, key_ring_id, id):
5151

5252
# Rotate the key every 30 days.
5353
'rotation_period': {
54-
'seconds': 60*60*24*30
54+
'seconds': 60 * 60 * 24 * 30
5555
},
5656

5757
# Start the first rotation in 24 hours.
5858
'next_rotation_time': {
59-
'seconds': int(time.time()) + 60*60*24
59+
'seconds': int(time.time()) + 60 * 60 * 24
6060
}
6161
}
6262

6363
# Call the API.
64-
created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key})
64+
created_key = client.create_crypto_key(
65+
request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key})
6566
print('Created labeled key: {}'.format(created_key.name))
6667
return created_key
6768
# [END kms_create_key_rotation_schedule]

kms/snippets/create_key_symmetric_encrypt_decrypt.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414

1515
# [START kms_create_key_symmetric_encrypt_decrypt]
16-
def create_key_symmetric_encrypt_decrypt(project_id, location_id, key_ring_id, id):
16+
def create_key_symmetric_encrypt_decrypt(project_id, location_id, key_ring_id, key_id):
1717
"""
1818
Creates a new symmetric encryption/decryption key in Cloud KMS.
1919
2020
Args:
2121
project_id (string): Google Cloud project ID (e.g. 'my-project').
2222
location_id (string): Cloud KMS location (e.g. 'us-east1').
2323
key_ring_id (string): ID of the Cloud KMS key ring (e.g. 'my-key-ring').
24-
id (string): ID of the key to create (e.g. 'my-symmetric-key').
24+
key_id (string): ID of the key to create (e.g. 'my-symmetric-key').
2525
2626
Returns:
2727
CryptoKey: Cloud KMS key.
@@ -43,12 +43,13 @@ def create_key_symmetric_encrypt_decrypt(project_id, location_id, key_ring_id, i
4343
key = {
4444
'purpose': purpose,
4545
'version_template': {
46-
'algorithm': algorithm,
46+
'algorithm': algorithm,
4747
}
4848
}
4949

5050
# Call the API.
51-
created_key = client.create_crypto_key(request={'parent': key_ring_name, 'crypto_key_id': id, 'crypto_key': key})
51+
created_key = client.create_crypto_key(
52+
request={'parent': key_ring_name, 'crypto_key_id': key_id, 'crypto_key': key})
5253
print('Created symmetric key: {}'.format(created_key.name))
5354
return created_key
5455
# [END kms_create_key_symmetric_encrypt_decrypt]

0 commit comments

Comments
 (0)