17
17
import base64
18
18
import io
19
19
20
- from googleapiclient import discovery
20
+ import googleapiclient . discovery
21
21
22
22
23
23
# [START kms_create_keyring]
24
24
def create_keyring (project_id , location , keyring ):
25
25
"""Creates a KeyRing in the given location (e.g. global)."""
26
26
27
27
# Creates an API client for the KMS API.
28
- kms_client = discovery .build ('cloudkms' , 'v1beta1' )
28
+ kms_client = googleapiclient . discovery .build ('cloudkms' , 'v1beta1' )
29
29
30
30
# The resource name of the location associated with the KeyRing.
31
31
parent = 'projects/{}/locations/{}' .format (project_id , location )
@@ -44,7 +44,7 @@ def create_cryptokey(project_id, location, keyring, cryptokey):
44
44
"""Creates a CryptoKey within a KeyRing in the given location."""
45
45
46
46
# Creates an API client for the KMS API.
47
- kms_client = discovery .build ('cloudkms' , 'v1beta1' )
47
+ kms_client = googleapiclient . discovery .build ('cloudkms' , 'v1beta1' )
48
48
49
49
# The resource name of the KeyRing associated with the CryptoKey.
50
50
parent = 'projects/{}/locations/{}/keyRings/{}' .format (
@@ -68,7 +68,7 @@ def encrypt(project_id, location, keyring, cryptokey, plaintext_file_name,
68
68
call to decrypt."""
69
69
70
70
# Creates an API client for the KMS API.
71
- kms_client = discovery .build ('cloudkms' , 'v1beta1' )
71
+ kms_client = googleapiclient . discovery .build ('cloudkms' , 'v1beta1' )
72
72
73
73
# The resource name of the CryptoKey.
74
74
name = 'projects/{}/locations/{}/keyRings/{}/cryptoKeys/{}' .format (
@@ -101,7 +101,7 @@ def decrypt(project_id, location, keyring, cryptokey, encrypted_file_name,
101
101
decrpyted_file_name."""
102
102
103
103
# Creates an API client for the KMS API.
104
- kms_client = discovery .build ('cloudkms' , 'v1beta1' )
104
+ kms_client = googleapiclient . discovery .build ('cloudkms' , 'v1beta1' )
105
105
106
106
# The resource name of the CryptoKey.
107
107
name = 'projects/{}/locations/{}/keyRings/{}/cryptoKeys/{}' .format (
@@ -134,7 +134,7 @@ def disable_cryptokey_version(project_id, location, keyring, cryptokey,
134
134
KeyRing."""
135
135
136
136
# Creates an API client for the KMS API.
137
- kms_client = discovery .build ('cloudkms' , 'v1beta1' )
137
+ kms_client = googleapiclient . discovery .build ('cloudkms' , 'v1beta1' )
138
138
139
139
# Construct the resource name of the CryptoKeyVersion.
140
140
name = (
@@ -160,7 +160,7 @@ def destroy_cryptokey_version(
160
160
KeyRing for destruction 24 hours in the future."""
161
161
162
162
# Creates an API client for the KMS API.
163
- kms_client = discovery .build ('cloudkms' , 'v1beta1' )
163
+ kms_client = googleapiclient . discovery .build ('cloudkms' , 'v1beta1' )
164
164
165
165
# Construct the resource name of the CryptoKeyVersion.
166
166
name = (
@@ -185,7 +185,7 @@ def add_member_to_cryptokey_policy(
185
185
(IAM) policy for a given CryptoKey associated with a KeyRing."""
186
186
187
187
# Creates an API client for the KMS API.
188
- kms_client = discovery .build ('cloudkms' , 'v1beta1' )
188
+ kms_client = googleapiclient . discovery .build ('cloudkms' , 'v1beta1' )
189
189
190
190
# The resource name of the CryptoKey.
191
191
parent = 'projects/{}/locations/{}/keyRings/{}/cryptoKeys/{}' .format (
@@ -225,7 +225,7 @@ def get_keyring_policy(project_id, location, keyring):
225
225
and prints out roles and the members assigned to those roles."""
226
226
227
227
# Creates an API client for the KMS API.
228
- kms_client = discovery .build ('cloudkms' , 'v1beta1' )
228
+ kms_client = googleapiclient . discovery .build ('cloudkms' , 'v1beta1' )
229
229
230
230
# The resource name of the KeyRing.
231
231
parent = 'projects/{}/locations/{}/keyRings/{}' .format (
0 commit comments