Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

feat: add common resource path helpers #74

Merged
merged 5 commits into from Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/kms_v1/types.rst
Expand Up @@ -3,3 +3,4 @@ Types for Google Cloud Kms v1 API

.. automodule:: google.cloud.kms_v1.types
:members:
:show-inheritance:
108 changes: 86 additions & 22 deletions google/cloud/kms_v1/services/key_management_service/async_client.py
Expand Up @@ -79,10 +79,52 @@ class KeyManagementServiceAsyncClient:
)
key_ring_path = staticmethod(KeyManagementServiceClient.key_ring_path)
parse_key_ring_path = staticmethod(KeyManagementServiceClient.parse_key_ring_path)
public_key_path = staticmethod(KeyManagementServiceClient.public_key_path)
parse_public_key_path = staticmethod(
KeyManagementServiceClient.parse_public_key_path
)

common_billing_account_path = staticmethod(
KeyManagementServiceClient.common_billing_account_path
)
parse_common_billing_account_path = staticmethod(
KeyManagementServiceClient.parse_common_billing_account_path
)

common_folder_path = staticmethod(KeyManagementServiceClient.common_folder_path)
parse_common_folder_path = staticmethod(
KeyManagementServiceClient.parse_common_folder_path
)

common_organization_path = staticmethod(
KeyManagementServiceClient.common_organization_path
)
parse_common_organization_path = staticmethod(
KeyManagementServiceClient.parse_common_organization_path
)

common_project_path = staticmethod(KeyManagementServiceClient.common_project_path)
parse_common_project_path = staticmethod(
KeyManagementServiceClient.parse_common_project_path
)

common_location_path = staticmethod(KeyManagementServiceClient.common_location_path)
parse_common_location_path = staticmethod(
KeyManagementServiceClient.parse_common_location_path
)

from_service_account_file = KeyManagementServiceClient.from_service_account_file
from_service_account_json = from_service_account_file

@property
def transport(self) -> KeyManagementServiceTransport:
"""Return the transport used by the client instance.

Returns:
KeyManagementServiceTransport: The transport used by the client instance.
"""
return self._client.transport

get_transport_class = functools.partial(
type(KeyManagementServiceClient).get_transport_class,
type(KeyManagementServiceClient),
Expand Down Expand Up @@ -179,7 +221,8 @@ async def list_key_rings(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([parent]):
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -271,7 +314,8 @@ async def list_crypto_keys(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([parent]):
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -364,7 +408,8 @@ async def list_crypto_key_versions(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([parent]):
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -456,7 +501,8 @@ async def list_import_jobs(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([parent]):
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -546,7 +592,8 @@ async def get_key_ring(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name]):
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -639,7 +686,8 @@ async def get_crypto_key(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name]):
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -737,7 +785,8 @@ async def get_crypto_key_version(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name]):
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -829,7 +878,8 @@ async def get_public_key(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name]):
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -956,7 +1006,8 @@ async def get_import_job(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name]):
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -1055,7 +1106,8 @@ async def create_key_ring(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([parent, key_ring_id, key_ring]):
has_flattened_params = any([parent, key_ring_id, key_ring])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -1168,7 +1220,8 @@ async def create_crypto_key(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([parent, crypto_key_id, crypto_key]):
has_flattened_params = any([parent, crypto_key_id, crypto_key])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -1284,7 +1337,8 @@ async def create_crypto_key_version(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([parent, crypto_key_version]):
has_flattened_params = any([parent, crypto_key_version])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -1491,7 +1545,8 @@ async def create_import_job(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([parent, import_job_id, import_job]):
has_flattened_params = any([parent, import_job_id, import_job])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -1591,7 +1646,8 @@ async def update_crypto_key(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([crypto_key, update_mask]):
has_flattened_params = any([crypto_key, update_mask])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -1711,7 +1767,8 @@ async def update_crypto_key_version(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([crypto_key_version, update_mask]):
has_flattened_params = any([crypto_key_version, update_mask])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -1824,7 +1881,8 @@ async def encrypt(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name, plaintext]):
has_flattened_params = any([name, plaintext])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -1921,7 +1979,8 @@ async def decrypt(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name, ciphertext]):
has_flattened_params = any([name, ciphertext])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -2020,7 +2079,8 @@ async def asymmetric_sign(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name, digest]):
has_flattened_params = any([name, digest])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -2119,7 +2179,8 @@ async def asymmetric_decrypt(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name, ciphertext]):
has_flattened_params = any([name, ciphertext])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -2222,7 +2283,8 @@ async def update_crypto_key_primary_version(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name, crypto_key_version_id]):
has_flattened_params = any([name, crypto_key_version_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -2340,7 +2402,8 @@ async def destroy_crypto_key_version(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name]):
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -2447,7 +2510,8 @@ async def restore_crypto_key_version(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
if request is not None and any([name]):
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down