Skip to content

Commit

Permalink
Remove usage of GoogleCredentials [(#810)](#810)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott authored and rsamborski committed Nov 11, 2022
1 parent 93b09d6 commit 371b2e5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions kms/snippets/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
def run_quickstart():
# [START kms_quickstart]
# Imports the Google APIs client library
from googleapiclient import discovery
import googleapiclient.discovery

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

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

# The resource name of the location associated with the key rings.
parent = 'projects/{}/locations/{}'.format(project_id, location)
Expand Down
18 changes: 9 additions & 9 deletions kms/snippets/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
import base64
import io

from googleapiclient import discovery
import googleapiclient.discovery


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

# The resource name of the KeyRing.
parent = 'projects/{}/locations/{}/keyRings/{}'.format(
Expand Down
4 changes: 2 additions & 2 deletions kms/snippets/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import random
import string

from googleapiclient import discovery
import googleapiclient.discovery

import snippets

Expand Down Expand Up @@ -122,7 +122,7 @@ def test_add_member_to_cryptokey_policy(capsys, cloud_config):
.format(MEMBER, ROLE, CRYPTOKEY, KEYRING))
assert expected in out

kms_client = discovery.build('cloudkms', 'v1beta1')
kms_client = googleapiclient.discovery.build('cloudkms', 'v1beta1')
parent = 'projects/{}/locations/{}/keyRings/{}/cryptoKeys/{}'.format(
cloud_config.project, LOCATION, KEYRING, CRYPTOKEY)
cryptokeys = kms_client.projects().locations().keyRings().cryptoKeys()
Expand Down

0 comments on commit 371b2e5

Please sign in to comment.