Skip to content

Commit 9a168dc

Browse files
Jon Wayne Parrottbusunkim96
Jon Wayne Parrott
authored andcommitted
Remove usage of GoogleCredentials [(#810)](GoogleCloudPlatform/python-docs-samples#810)
1 parent 775abf7 commit 9a168dc

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

packages/google-cloud-kms/samples/snippets/quickstart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
def run_quickstart():
1818
# [START kms_quickstart]
1919
# Imports the Google APIs client library
20-
from googleapiclient import discovery
20+
import googleapiclient.discovery
2121

2222
# Your Google Cloud Platform project ID
2323
project_id = 'YOUR_PROJECT_ID'
@@ -26,7 +26,7 @@ def run_quickstart():
2626
location = 'global'
2727

2828
# Creates an API client for the KMS API.
29-
kms_client = discovery.build('cloudkms', 'v1beta1')
29+
kms_client = googleapiclient.discovery.build('cloudkms', 'v1beta1')
3030

3131
# The resource name of the location associated with the key rings.
3232
parent = 'projects/{}/locations/{}'.format(project_id, location)

packages/google-cloud-kms/samples/snippets/snippets.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
import base64
1818
import io
1919

20-
from googleapiclient import discovery
20+
import googleapiclient.discovery
2121

2222

2323
# [START kms_create_keyring]
2424
def create_keyring(project_id, location, keyring):
2525
"""Creates a KeyRing in the given location (e.g. global)."""
2626

2727
# Creates an API client for the KMS API.
28-
kms_client = discovery.build('cloudkms', 'v1beta1')
28+
kms_client = googleapiclient.discovery.build('cloudkms', 'v1beta1')
2929

3030
# The resource name of the location associated with the KeyRing.
3131
parent = 'projects/{}/locations/{}'.format(project_id, location)
@@ -44,7 +44,7 @@ def create_cryptokey(project_id, location, keyring, cryptokey):
4444
"""Creates a CryptoKey within a KeyRing in the given location."""
4545

4646
# Creates an API client for the KMS API.
47-
kms_client = discovery.build('cloudkms', 'v1beta1')
47+
kms_client = googleapiclient.discovery.build('cloudkms', 'v1beta1')
4848

4949
# The resource name of the KeyRing associated with the CryptoKey.
5050
parent = 'projects/{}/locations/{}/keyRings/{}'.format(
@@ -68,7 +68,7 @@ def encrypt(project_id, location, keyring, cryptokey, plaintext_file_name,
6868
call to decrypt."""
6969

7070
# Creates an API client for the KMS API.
71-
kms_client = discovery.build('cloudkms', 'v1beta1')
71+
kms_client = googleapiclient.discovery.build('cloudkms', 'v1beta1')
7272

7373
# The resource name of the CryptoKey.
7474
name = 'projects/{}/locations/{}/keyRings/{}/cryptoKeys/{}'.format(
@@ -101,7 +101,7 @@ def decrypt(project_id, location, keyring, cryptokey, encrypted_file_name,
101101
decrpyted_file_name."""
102102

103103
# Creates an API client for the KMS API.
104-
kms_client = discovery.build('cloudkms', 'v1beta1')
104+
kms_client = googleapiclient.discovery.build('cloudkms', 'v1beta1')
105105

106106
# The resource name of the CryptoKey.
107107
name = 'projects/{}/locations/{}/keyRings/{}/cryptoKeys/{}'.format(
@@ -134,7 +134,7 @@ def disable_cryptokey_version(project_id, location, keyring, cryptokey,
134134
KeyRing."""
135135

136136
# Creates an API client for the KMS API.
137-
kms_client = discovery.build('cloudkms', 'v1beta1')
137+
kms_client = googleapiclient.discovery.build('cloudkms', 'v1beta1')
138138

139139
# Construct the resource name of the CryptoKeyVersion.
140140
name = (
@@ -160,7 +160,7 @@ def destroy_cryptokey_version(
160160
KeyRing for destruction 24 hours in the future."""
161161

162162
# Creates an API client for the KMS API.
163-
kms_client = discovery.build('cloudkms', 'v1beta1')
163+
kms_client = googleapiclient.discovery.build('cloudkms', 'v1beta1')
164164

165165
# Construct the resource name of the CryptoKeyVersion.
166166
name = (
@@ -185,7 +185,7 @@ def add_member_to_cryptokey_policy(
185185
(IAM) policy for a given CryptoKey associated with a KeyRing."""
186186

187187
# Creates an API client for the KMS API.
188-
kms_client = discovery.build('cloudkms', 'v1beta1')
188+
kms_client = googleapiclient.discovery.build('cloudkms', 'v1beta1')
189189

190190
# The resource name of the CryptoKey.
191191
parent = 'projects/{}/locations/{}/keyRings/{}/cryptoKeys/{}'.format(
@@ -225,7 +225,7 @@ def get_keyring_policy(project_id, location, keyring):
225225
and prints out roles and the members assigned to those roles."""
226226

227227
# Creates an API client for the KMS API.
228-
kms_client = discovery.build('cloudkms', 'v1beta1')
228+
kms_client = googleapiclient.discovery.build('cloudkms', 'v1beta1')
229229

230230
# The resource name of the KeyRing.
231231
parent = 'projects/{}/locations/{}/keyRings/{}'.format(

packages/google-cloud-kms/samples/snippets/snippets_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import random
1717
import string
1818

19-
from googleapiclient import discovery
19+
import googleapiclient.discovery
2020

2121
import snippets
2222

@@ -122,7 +122,7 @@ def test_add_member_to_cryptokey_policy(capsys, cloud_config):
122122
.format(MEMBER, ROLE, CRYPTOKEY, KEYRING))
123123
assert expected in out
124124

125-
kms_client = discovery.build('cloudkms', 'v1beta1')
125+
kms_client = googleapiclient.discovery.build('cloudkms', 'v1beta1')
126126
parent = 'projects/{}/locations/{}/keyRings/{}/cryptoKeys/{}'.format(
127127
cloud_config.project, LOCATION, KEYRING, CRYPTOKEY)
128128
cryptokeys = kms_client.projects().locations().keyRings().cryptoKeys()

0 commit comments

Comments
 (0)