diff --git a/kms/snippets/quickstart.py b/kms/snippets/quickstart.py index 4e94a669118a..f4e4c7bed61b 100644 --- a/kms/snippets/quickstart.py +++ b/kms/snippets/quickstart.py @@ -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' @@ -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) diff --git a/kms/snippets/snippets.py b/kms/snippets/snippets.py index 9469b9398dd8..1c0a52923920 100644 --- a/kms/snippets/snippets.py +++ b/kms/snippets/snippets.py @@ -17,7 +17,7 @@ import base64 import io -from googleapiclient import discovery +import googleapiclient.discovery # [START kms_create_keyring] @@ -25,7 +25,7 @@ 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) @@ -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( @@ -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( @@ -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( @@ -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 = ( @@ -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 = ( @@ -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( @@ -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( diff --git a/kms/snippets/snippets_test.py b/kms/snippets/snippets_test.py index 2ea0b12c3a54..dc532bcea346 100644 --- a/kms/snippets/snippets_test.py +++ b/kms/snippets/snippets_test.py @@ -16,7 +16,7 @@ import random import string -from googleapiclient import discovery +import googleapiclient.discovery import snippets @@ -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()