From 9b674de1429a4fca4d31d2ae9f354dcb026cd316 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 13:55:14 +0000 Subject: [PATCH] feat: [google-cloud-tasks] Add support for opt-in debug logging (#13331) BEGIN_COMMIT_OVERRIDE feat: Add support for opt-in debug logging fix: Fix typing issue with gRPC metadata when key ends in -bin chore: Update gapic-generator-python to v1.21.0 END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. fix: Fix typing issue with gRPC metadata when key ends in -bin chore: Update gapic-generator-python to v1.21.0 PiperOrigin-RevId: 705285820 Source-Link: https://github.com/googleapis/googleapis/commit/f9b8b9150f7fcd600b0acaeef91236b1843f5e49 Source-Link: https://github.com/googleapis/googleapis-gen/commit/ca1e0a1e472d6e6f5de883a5cb54724f112ce348 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXRhc2tzLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= BEGIN_NESTED_COMMIT feat!: [google-cloud-tasks] Switched from the nonfunctional gRPC backend to REST feat!: Updated from v1beta1 to v1 of the service PiperOrigin-RevId: 703191966 Source-Link: https://github.com/googleapis/googleapis/commit/c53320c8d007c134e59bdc83f434acb51b7c9ac2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/32a69c3ac309e9c33950e85bc947ff58b1d77387 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXRhc2tzLy5Pd2xCb3QueWFtbCIsImgiOiIzMmE2OWMzYWMzMDllOWMzMzk1MGU4NWJjOTQ3ZmY1OGIxZDc3Mzg3In0= END_NESTED_COMMIT --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../google/cloud/tasks/gapic_version.py | 2 +- .../google/cloud/tasks_v2/gapic_version.py | 2 +- .../services/cloud_tasks/async_client.py | 176 ++- .../tasks_v2/services/cloud_tasks/client.py | 181 ++- .../tasks_v2/services/cloud_tasks/pagers.py | 32 +- .../services/cloud_tasks/transports/grpc.py | 126 +- .../cloud_tasks/transports/grpc_asyncio.py | 125 +- .../services/cloud_tasks/transports/rest.py | 1109 ++++++++++++-- .../cloud/tasks_v2beta2/gapic_version.py | 2 +- .../services/cloud_tasks/async_client.py | 216 ++- .../services/cloud_tasks/client.py | 221 ++- .../services/cloud_tasks/pagers.py | 32 +- .../services/cloud_tasks/transports/grpc.py | 136 +- .../cloud_tasks/transports/grpc_asyncio.py | 135 +- .../services/cloud_tasks/transports/rest.py | 1343 +++++++++++++++-- .../cloud/tasks_v2beta3/gapic_version.py | 2 +- .../services/cloud_tasks/async_client.py | 176 ++- .../services/cloud_tasks/client.py | 181 ++- .../services/cloud_tasks/pagers.py | 32 +- .../services/cloud_tasks/transports/grpc.py | 126 +- .../cloud_tasks/transports/grpc_asyncio.py | 125 +- .../services/cloud_tasks/transports/rest.py | 1109 ++++++++++++-- ...nippet_metadata_google.cloud.tasks.v2.json | 66 +- ...t_metadata_google.cloud.tasks.v2beta2.json | 86 +- ...t_metadata_google.cloud.tasks.v2beta3.json | 66 +- .../tasks-v2beta2-py.tar.gz | 0 .../unit/gapic/tasks_v2/test_cloud_tasks.py | 84 ++ .../gapic/tasks_v2beta2/test_cloud_tasks.py | 104 ++ .../gapic/tasks_v2beta3/test_cloud_tasks.py | 84 ++ 29 files changed, 5152 insertions(+), 927 deletions(-) create mode 100644 packages/google-cloud-tasks/tasks-v2beta2-py.tar.gz diff --git a/packages/google-cloud-tasks/google/cloud/tasks/gapic_version.py b/packages/google-cloud-tasks/google/cloud/tasks/gapic_version.py index 6fecc94eb049..558c8aab67c5 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks/gapic_version.py +++ b/packages/google-cloud-tasks/google/cloud/tasks/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.17.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2/gapic_version.py b/packages/google-cloud-tasks/google/cloud/tasks_v2/gapic_version.py index 6fecc94eb049..558c8aab67c5 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2/gapic_version.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.17.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/async_client.py b/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/async_client.py index 88786a69f9e9..7c900c4b9c1e 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/async_client.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CloudTasksTransport from .transports.grpc_asyncio import CloudTasksGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class CloudTasksAsyncClient: """Cloud Tasks allows developers to manage the execution of @@ -264,6 +274,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.tasks_v2.CloudTasksAsyncClient`.", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "universeDomain": getattr( + self._client._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._client._transport, "_credentials") + else { + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "credentialsType": None, + }, + ) + async def list_queues( self, request: Optional[Union[cloudtasks.ListQueuesRequest, dict]] = None, @@ -271,7 +303,7 @@ async def list_queues( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListQueuesAsyncPager: r"""Lists queues. @@ -318,8 +350,10 @@ async def sample_list_queues(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.services.cloud_tasks.pagers.ListQueuesAsyncPager: @@ -394,7 +428,7 @@ async def get_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Gets a queue. @@ -438,8 +472,10 @@ async def sample_get_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Queue: @@ -505,7 +541,7 @@ async def create_queue( queue: Optional[gct_queue.Queue] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Creates a queue. @@ -573,8 +609,10 @@ async def sample_create_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Queue: @@ -642,7 +680,7 @@ async def update_queue( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Updates a queue. @@ -715,8 +753,10 @@ async def sample_update_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Queue: @@ -785,7 +825,7 @@ async def delete_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a queue. @@ -837,8 +877,10 @@ async def sample_delete_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -890,7 +932,7 @@ async def purge_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Purges a queue by deleting all of its tasks. @@ -941,8 +983,10 @@ async def sample_purge_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Queue: @@ -1007,7 +1051,7 @@ async def pause_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Pauses the queue. @@ -1058,8 +1102,10 @@ async def sample_pause_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Queue: @@ -1124,7 +1170,7 @@ async def resume_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Resume a queue. @@ -1182,8 +1228,10 @@ async def sample_resume_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Queue: @@ -1248,7 +1296,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a [Queue][google.cloud.tasks.v2.Queue]. Returns an empty policy if @@ -1302,8 +1350,10 @@ async def sample_get_iam_policy(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -1389,7 +1439,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy for a [Queue][google.cloud.tasks.v2.Queue]. Replaces any existing @@ -1447,8 +1497,10 @@ async def sample_set_iam_policy(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -1535,7 +1587,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2.Queue]. If the resource does not @@ -1599,8 +1651,10 @@ async def sample_test_iam_permissions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1658,7 +1712,7 @@ async def list_tasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTasksAsyncPager: r"""Lists the tasks in a queue. @@ -1712,8 +1766,10 @@ async def sample_list_tasks(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.services.cloud_tasks.pagers.ListTasksAsyncPager: @@ -1788,7 +1844,7 @@ async def get_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Gets a task. @@ -1832,8 +1888,10 @@ async def sample_get_task(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Task: @@ -1891,7 +1949,7 @@ async def create_task( task: Optional[gct_task.Task] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_task.Task: r"""Creates a task and adds it to a queue. @@ -1988,8 +2046,10 @@ async def sample_create_task(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Task: @@ -2050,7 +2110,7 @@ async def delete_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a task. @@ -2095,8 +2155,10 @@ async def sample_delete_task(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2148,7 +2210,7 @@ async def run_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Forces a task to run now. @@ -2218,8 +2280,10 @@ async def sample_run_task(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Task: @@ -2275,7 +2339,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2286,8 +2350,10 @@ async def get_location( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.location_pb2.Location: Location object. @@ -2328,7 +2394,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2339,8 +2405,10 @@ async def list_locations( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/client.py b/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/client.py index b2116861618c..0011a9677f64 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/client.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -614,6 +624,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -676,6 +690,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.tasks_v2.CloudTasksClient`.", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._transport, "_credentials") + else { + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "credentialsType": None, + }, + ) + def list_queues( self, request: Optional[Union[cloudtasks.ListQueuesRequest, dict]] = None, @@ -683,7 +720,7 @@ def list_queues( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListQueuesPager: r"""Lists queues. @@ -730,8 +767,10 @@ def sample_list_queues(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.services.cloud_tasks.pagers.ListQueuesPager: @@ -803,7 +842,7 @@ def get_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Gets a queue. @@ -847,8 +886,10 @@ def sample_get_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Queue: @@ -911,7 +952,7 @@ def create_queue( queue: Optional[gct_queue.Queue] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Creates a queue. @@ -979,8 +1020,10 @@ def sample_create_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Queue: @@ -1045,7 +1088,7 @@ def update_queue( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Updates a queue. @@ -1118,8 +1161,10 @@ def sample_update_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Queue: @@ -1185,7 +1230,7 @@ def delete_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a queue. @@ -1237,8 +1282,10 @@ def sample_delete_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1287,7 +1334,7 @@ def purge_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Purges a queue by deleting all of its tasks. @@ -1338,8 +1385,10 @@ def sample_purge_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Queue: @@ -1401,7 +1450,7 @@ def pause_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Pauses the queue. @@ -1452,8 +1501,10 @@ def sample_pause_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Queue: @@ -1515,7 +1566,7 @@ def resume_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Resume a queue. @@ -1573,8 +1624,10 @@ def sample_resume_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Queue: @@ -1636,7 +1689,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a [Queue][google.cloud.tasks.v2.Queue]. Returns an empty policy if @@ -1690,8 +1743,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -1778,7 +1833,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy for a [Queue][google.cloud.tasks.v2.Queue]. Replaces any existing @@ -1836,8 +1891,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -1925,7 +1982,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2.Queue]. If the resource does not @@ -1989,8 +2046,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2049,7 +2108,7 @@ def list_tasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTasksPager: r"""Lists the tasks in a queue. @@ -2103,8 +2162,10 @@ def sample_list_tasks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.services.cloud_tasks.pagers.ListTasksPager: @@ -2176,7 +2237,7 @@ def get_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Gets a task. @@ -2220,8 +2281,10 @@ def sample_get_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Task: @@ -2278,7 +2341,7 @@ def create_task( task: Optional[gct_task.Task] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_task.Task: r"""Creates a task and adds it to a queue. @@ -2375,8 +2438,10 @@ def sample_create_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Task: @@ -2434,7 +2499,7 @@ def delete_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a task. @@ -2479,8 +2544,10 @@ def sample_delete_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2529,7 +2596,7 @@ def run_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Forces a task to run now. @@ -2599,8 +2666,10 @@ def sample_run_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2.types.Task: @@ -2668,7 +2737,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2679,8 +2748,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.location_pb2.Location: Location object. @@ -2721,7 +2792,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2732,8 +2803,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/pagers.py b/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/pagers.py index 40bd99212b95..240e8e7aecf3 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/pagers.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloudtasks.ListQueuesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloudtasks.ListQueuesRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloudtasks.ListTasksRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloudtasks.ListTasksRequest(request) diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc.py b/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc.py index bfb3f92dcddc..5af4839c7e92 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,7 +27,10 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.tasks_v2.types import cloudtasks from google.cloud.tasks_v2.types import queue @@ -34,6 +40,81 @@ from .base import DEFAULT_CLIENT_INFO, CloudTasksTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER + def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": client_call_details.method, + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + + response = continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = response.result() + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response for {client_call_details.method}.", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudTasksGrpcTransport(CloudTasksTransport): """gRPC backend transport for CloudTasks. @@ -188,7 +269,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -264,7 +350,7 @@ def list_queues( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_queues" not in self._stubs: - self._stubs["list_queues"] = self.grpc_channel.unary_unary( + self._stubs["list_queues"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/ListQueues", request_serializer=cloudtasks.ListQueuesRequest.serialize, response_deserializer=cloudtasks.ListQueuesResponse.deserialize, @@ -288,7 +374,7 @@ def get_queue(self) -> Callable[[cloudtasks.GetQueueRequest], queue.Queue]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_queue" not in self._stubs: - self._stubs["get_queue"] = self.grpc_channel.unary_unary( + self._stubs["get_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/GetQueue", request_serializer=cloudtasks.GetQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -324,7 +410,7 @@ def create_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_queue" not in self._stubs: - self._stubs["create_queue"] = self.grpc_channel.unary_unary( + self._stubs["create_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/CreateQueue", request_serializer=cloudtasks.CreateQueueRequest.serialize, response_deserializer=gct_queue.Queue.deserialize, @@ -363,7 +449,7 @@ def update_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_queue" not in self._stubs: - self._stubs["update_queue"] = self.grpc_channel.unary_unary( + self._stubs["update_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/UpdateQueue", request_serializer=cloudtasks.UpdateQueueRequest.serialize, response_deserializer=gct_queue.Queue.deserialize, @@ -400,7 +486,7 @@ def delete_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_queue" not in self._stubs: - self._stubs["delete_queue"] = self.grpc_channel.unary_unary( + self._stubs["delete_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/DeleteQueue", request_serializer=cloudtasks.DeleteQueueRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -431,7 +517,7 @@ def purge_queue(self) -> Callable[[cloudtasks.PurgeQueueRequest], queue.Queue]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_queue" not in self._stubs: - self._stubs["purge_queue"] = self.grpc_channel.unary_unary( + self._stubs["purge_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/PurgeQueue", request_serializer=cloudtasks.PurgeQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -462,7 +548,7 @@ def pause_queue(self) -> Callable[[cloudtasks.PauseQueueRequest], queue.Queue]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_queue" not in self._stubs: - self._stubs["pause_queue"] = self.grpc_channel.unary_unary( + self._stubs["pause_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/PauseQueue", request_serializer=cloudtasks.PauseQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -500,7 +586,7 @@ def resume_queue(self) -> Callable[[cloudtasks.ResumeQueueRequest], queue.Queue] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_queue" not in self._stubs: - self._stubs["resume_queue"] = self.grpc_channel.unary_unary( + self._stubs["resume_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/ResumeQueue", request_serializer=cloudtasks.ResumeQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -534,7 +620,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -572,7 +658,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -609,7 +695,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -644,7 +730,7 @@ def list_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tasks" not in self._stubs: - self._stubs["list_tasks"] = self.grpc_channel.unary_unary( + self._stubs["list_tasks"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/ListTasks", request_serializer=cloudtasks.ListTasksRequest.serialize, response_deserializer=cloudtasks.ListTasksResponse.deserialize, @@ -668,7 +754,7 @@ def get_task(self) -> Callable[[cloudtasks.GetTaskRequest], task.Task]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task" not in self._stubs: - self._stubs["get_task"] = self.grpc_channel.unary_unary( + self._stubs["get_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/GetTask", request_serializer=cloudtasks.GetTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -697,7 +783,7 @@ def create_task(self) -> Callable[[cloudtasks.CreateTaskRequest], gct_task.Task] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_task" not in self._stubs: - self._stubs["create_task"] = self.grpc_channel.unary_unary( + self._stubs["create_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/CreateTask", request_serializer=cloudtasks.CreateTaskRequest.serialize, response_deserializer=gct_task.Task.deserialize, @@ -725,7 +811,7 @@ def delete_task(self) -> Callable[[cloudtasks.DeleteTaskRequest], empty_pb2.Empt # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_task" not in self._stubs: - self._stubs["delete_task"] = self.grpc_channel.unary_unary( + self._stubs["delete_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/DeleteTask", request_serializer=cloudtasks.DeleteTaskRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -775,7 +861,7 @@ def run_task(self) -> Callable[[cloudtasks.RunTaskRequest], task.Task]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_task" not in self._stubs: - self._stubs["run_task"] = self.grpc_channel.unary_unary( + self._stubs["run_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/RunTask", request_serializer=cloudtasks.RunTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -783,7 +869,7 @@ def run_task(self) -> Callable[[cloudtasks.RunTaskRequest], task.Task]: return self._stubs["run_task"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -797,7 +883,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -814,7 +900,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc_asyncio.py b/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc_asyncio.py index 1f4485974214..8cc4762ecd6b 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc_asyncio.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,8 +29,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.tasks_v2.types import cloudtasks from google.cloud.tasks_v2.types import queue @@ -38,6 +44,82 @@ from .base import DEFAULT_CLIENT_INFO, CloudTasksTransport from .grpc import CloudTasksGrpcTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientAIOInterceptor( + grpc.aio.UnaryUnaryClientInterceptor +): # pragma: NO COVER + async def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = await continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = await response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = await response + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response to rpc {client_call_details.method}.", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudTasksGrpcAsyncIOTransport(CloudTasksTransport): """gRPC AsyncIO backend transport for CloudTasks. @@ -235,10 +317,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -274,7 +359,7 @@ def list_queues( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_queues" not in self._stubs: - self._stubs["list_queues"] = self.grpc_channel.unary_unary( + self._stubs["list_queues"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/ListQueues", request_serializer=cloudtasks.ListQueuesRequest.serialize, response_deserializer=cloudtasks.ListQueuesResponse.deserialize, @@ -300,7 +385,7 @@ def get_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_queue" not in self._stubs: - self._stubs["get_queue"] = self.grpc_channel.unary_unary( + self._stubs["get_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/GetQueue", request_serializer=cloudtasks.GetQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -336,7 +421,7 @@ def create_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_queue" not in self._stubs: - self._stubs["create_queue"] = self.grpc_channel.unary_unary( + self._stubs["create_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/CreateQueue", request_serializer=cloudtasks.CreateQueueRequest.serialize, response_deserializer=gct_queue.Queue.deserialize, @@ -375,7 +460,7 @@ def update_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_queue" not in self._stubs: - self._stubs["update_queue"] = self.grpc_channel.unary_unary( + self._stubs["update_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/UpdateQueue", request_serializer=cloudtasks.UpdateQueueRequest.serialize, response_deserializer=gct_queue.Queue.deserialize, @@ -412,7 +497,7 @@ def delete_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_queue" not in self._stubs: - self._stubs["delete_queue"] = self.grpc_channel.unary_unary( + self._stubs["delete_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/DeleteQueue", request_serializer=cloudtasks.DeleteQueueRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -445,7 +530,7 @@ def purge_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_queue" not in self._stubs: - self._stubs["purge_queue"] = self.grpc_channel.unary_unary( + self._stubs["purge_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/PurgeQueue", request_serializer=cloudtasks.PurgeQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -478,7 +563,7 @@ def pause_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_queue" not in self._stubs: - self._stubs["pause_queue"] = self.grpc_channel.unary_unary( + self._stubs["pause_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/PauseQueue", request_serializer=cloudtasks.PauseQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -518,7 +603,7 @@ def resume_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_queue" not in self._stubs: - self._stubs["resume_queue"] = self.grpc_channel.unary_unary( + self._stubs["resume_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/ResumeQueue", request_serializer=cloudtasks.ResumeQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -552,7 +637,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -590,7 +675,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -627,7 +712,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -664,7 +749,7 @@ def list_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tasks" not in self._stubs: - self._stubs["list_tasks"] = self.grpc_channel.unary_unary( + self._stubs["list_tasks"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/ListTasks", request_serializer=cloudtasks.ListTasksRequest.serialize, response_deserializer=cloudtasks.ListTasksResponse.deserialize, @@ -688,7 +773,7 @@ def get_task(self) -> Callable[[cloudtasks.GetTaskRequest], Awaitable[task.Task] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task" not in self._stubs: - self._stubs["get_task"] = self.grpc_channel.unary_unary( + self._stubs["get_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/GetTask", request_serializer=cloudtasks.GetTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -719,7 +804,7 @@ def create_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_task" not in self._stubs: - self._stubs["create_task"] = self.grpc_channel.unary_unary( + self._stubs["create_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/CreateTask", request_serializer=cloudtasks.CreateTaskRequest.serialize, response_deserializer=gct_task.Task.deserialize, @@ -749,7 +834,7 @@ def delete_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_task" not in self._stubs: - self._stubs["delete_task"] = self.grpc_channel.unary_unary( + self._stubs["delete_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/DeleteTask", request_serializer=cloudtasks.DeleteTaskRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -799,7 +884,7 @@ def run_task(self) -> Callable[[cloudtasks.RunTaskRequest], Awaitable[task.Task] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_task" not in self._stubs: - self._stubs["run_task"] = self.grpc_channel.unary_unary( + self._stubs["run_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2.CloudTasks/RunTask", request_serializer=cloudtasks.RunTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -987,7 +1072,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1005,7 +1090,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1022,7 +1107,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/transports/rest.py b/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/transports/rest.py index 77f053d32955..1f63d3f54c47 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/transports/rest.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2/services/cloud_tasks/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -45,6 +45,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -197,8 +205,8 @@ def post_update_queue(self, response): def pre_create_queue( self, request: cloudtasks.CreateQueueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.CreateQueueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.CreateQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_queue Override in a subclass to manipulate the request or metadata @@ -216,8 +224,10 @@ def post_create_queue(self, response: gct_queue.Queue) -> gct_queue.Queue: return response def pre_create_task( - self, request: cloudtasks.CreateTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.CreateTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.CreateTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.CreateTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_task Override in a subclass to manipulate the request or metadata @@ -237,8 +247,8 @@ def post_create_task(self, response: gct_task.Task) -> gct_task.Task: def pre_delete_queue( self, request: cloudtasks.DeleteQueueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.DeleteQueueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.DeleteQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_queue Override in a subclass to manipulate the request or metadata @@ -247,8 +257,10 @@ def pre_delete_queue( return request, metadata def pre_delete_task( - self, request: cloudtasks.DeleteTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.DeleteTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.DeleteTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.DeleteTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_task Override in a subclass to manipulate the request or metadata @@ -259,8 +271,10 @@ def pre_delete_task( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -278,8 +292,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: return response def pre_get_queue( - self, request: cloudtasks.GetQueueRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.GetQueueRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.GetQueueRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.GetQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_queue Override in a subclass to manipulate the request or metadata @@ -297,8 +313,10 @@ def post_get_queue(self, response: queue.Queue) -> queue.Queue: return response def pre_get_task( - self, request: cloudtasks.GetTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.GetTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.GetTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.GetTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_task Override in a subclass to manipulate the request or metadata @@ -316,8 +334,10 @@ def post_get_task(self, response: task.Task) -> task.Task: return response def pre_list_queues( - self, request: cloudtasks.ListQueuesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.ListQueuesRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.ListQueuesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.ListQueuesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_queues Override in a subclass to manipulate the request or metadata @@ -337,8 +357,10 @@ def post_list_queues( return response def pre_list_tasks( - self, request: cloudtasks.ListTasksRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.ListTasksRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.ListTasksRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.ListTasksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tasks Override in a subclass to manipulate the request or metadata @@ -358,8 +380,10 @@ def post_list_tasks( return response def pre_pause_queue( - self, request: cloudtasks.PauseQueueRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.PauseQueueRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.PauseQueueRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.PauseQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for pause_queue Override in a subclass to manipulate the request or metadata @@ -377,8 +401,10 @@ def post_pause_queue(self, response: queue.Queue) -> queue.Queue: return response def pre_purge_queue( - self, request: cloudtasks.PurgeQueueRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.PurgeQueueRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.PurgeQueueRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.PurgeQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for purge_queue Override in a subclass to manipulate the request or metadata @@ -398,8 +424,8 @@ def post_purge_queue(self, response: queue.Queue) -> queue.Queue: def pre_resume_queue( self, request: cloudtasks.ResumeQueueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.ResumeQueueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.ResumeQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for resume_queue Override in a subclass to manipulate the request or metadata @@ -417,8 +443,10 @@ def post_resume_queue(self, response: queue.Queue) -> queue.Queue: return response def pre_run_task( - self, request: cloudtasks.RunTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.RunTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.RunTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.RunTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for run_task Override in a subclass to manipulate the request or metadata @@ -438,8 +466,10 @@ def post_run_task(self, response: task.Task) -> task.Task: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -459,8 +489,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -482,8 +515,8 @@ def post_test_iam_permissions( def pre_update_queue( self, request: cloudtasks.UpdateQueueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.UpdateQueueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.UpdateQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_queue Override in a subclass to manipulate the request or metadata @@ -503,8 +536,10 @@ def post_update_queue(self, response: gct_queue.Queue) -> gct_queue.Queue: def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -526,8 +561,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -669,7 +706,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Call the create queue method over HTTP. @@ -680,8 +717,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gct_queue.Queue: @@ -697,6 +736,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseCreateQueue._get_http_options() ) + request, metadata = self._interceptor.pre_create_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseCreateQueue._get_transcoded_request( @@ -715,6 +755,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.CreateQueue", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "CreateQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._CreateQueue._get_response( self._host, @@ -736,7 +803,29 @@ def __call__( pb_resp = gct_queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.create_queue", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "CreateQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTask(_BaseCloudTasksRestTransport._BaseCreateTask, CloudTasksRestStub): @@ -772,7 +861,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_task.Task: r"""Call the create task method over HTTP. @@ -783,8 +872,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gct_task.Task: @@ -794,6 +885,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseCreateTask._get_http_options() ) + request, metadata = self._interceptor.pre_create_task(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseCreateTask._get_transcoded_request( @@ -812,6 +904,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.CreateTask", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "CreateTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._CreateTask._get_response( self._host, @@ -833,7 +952,29 @@ def __call__( pb_resp = gct_task.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_task.Task.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.create_task", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "CreateTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteQueue( @@ -870,7 +1011,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete queue method over HTTP. @@ -881,13 +1022,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseCloudTasksRestTransport._BaseDeleteQueue._get_http_options() ) + request, metadata = self._interceptor.pre_delete_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseDeleteQueue._get_transcoded_request( @@ -902,6 +1046,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.DeleteQueue", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "DeleteQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._DeleteQueue._get_response( self._host, @@ -949,7 +1120,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete task method over HTTP. @@ -960,13 +1131,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseCloudTasksRestTransport._BaseDeleteTask._get_http_options() ) + request, metadata = self._interceptor.pre_delete_task(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseDeleteTask._get_transcoded_request( @@ -981,6 +1155,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.DeleteTask", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "DeleteTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._DeleteTask._get_response( self._host, @@ -1031,7 +1232,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1041,8 +1242,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.policy_pb2.Policy: @@ -1127,6 +1330,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -1147,6 +1351,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._GetIamPolicy._get_response( self._host, @@ -1168,7 +1399,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetQueue(_BaseCloudTasksRestTransport._BaseGetQueue, CloudTasksRestStub): @@ -1203,7 +1456,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Call the get queue method over HTTP. @@ -1214,8 +1467,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.queue.Queue: @@ -1231,6 +1486,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseGetQueue._get_http_options() ) + request, metadata = self._interceptor.pre_get_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseGetQueue._get_transcoded_request( @@ -1245,6 +1501,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.GetQueue", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "GetQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._GetQueue._get_response( self._host, @@ -1265,7 +1548,29 @@ def __call__( pb_resp = queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.get_queue", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "GetQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTask(_BaseCloudTasksRestTransport._BaseGetTask, CloudTasksRestStub): @@ -1300,7 +1605,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Call the get task method over HTTP. @@ -1311,8 +1616,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.task.Task: @@ -1320,6 +1627,7 @@ def __call__( """ http_options = _BaseCloudTasksRestTransport._BaseGetTask._get_http_options() + request, metadata = self._interceptor.pre_get_task(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseGetTask._get_transcoded_request( @@ -1334,6 +1642,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.GetTask", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "GetTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._GetTask._get_response( self._host, @@ -1354,7 +1689,29 @@ def __call__( pb_resp = task.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = task.Task.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.get_task", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "GetTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListQueues(_BaseCloudTasksRestTransport._BaseListQueues, CloudTasksRestStub): @@ -1389,7 +1746,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudtasks.ListQueuesResponse: r"""Call the list queues method over HTTP. @@ -1400,8 +1757,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudtasks.ListQueuesResponse: @@ -1413,6 +1772,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseListQueues._get_http_options() ) + request, metadata = self._interceptor.pre_list_queues(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseListQueues._get_transcoded_request( @@ -1427,6 +1787,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.ListQueues", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "ListQueues", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._ListQueues._get_response( self._host, @@ -1447,7 +1834,29 @@ def __call__( pb_resp = cloudtasks.ListQueuesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_queues(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudtasks.ListQueuesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.list_queues", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "ListQueues", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTasks(_BaseCloudTasksRestTransport._BaseListTasks, CloudTasksRestStub): @@ -1482,7 +1891,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudtasks.ListTasksResponse: r"""Call the list tasks method over HTTP. @@ -1493,8 +1902,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudtasks.ListTasksResponse: @@ -1506,6 +1917,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseListTasks._get_http_options() ) + request, metadata = self._interceptor.pre_list_tasks(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseListTasks._get_transcoded_request( @@ -1520,6 +1932,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.ListTasks", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "ListTasks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._ListTasks._get_response( self._host, @@ -1540,7 +1979,29 @@ def __call__( pb_resp = cloudtasks.ListTasksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tasks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudtasks.ListTasksResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.list_tasks", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "ListTasks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PauseQueue(_BaseCloudTasksRestTransport._BasePauseQueue, CloudTasksRestStub): @@ -1576,7 +2037,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Call the pause queue method over HTTP. @@ -1587,8 +2048,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.queue.Queue: @@ -1604,6 +2067,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BasePauseQueue._get_http_options() ) + request, metadata = self._interceptor.pre_pause_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BasePauseQueue._get_transcoded_request( @@ -1622,6 +2086,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.PauseQueue", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "PauseQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._PauseQueue._get_response( self._host, @@ -1643,7 +2134,29 @@ def __call__( pb_resp = queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_pause_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.pause_queue", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "PauseQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeQueue(_BaseCloudTasksRestTransport._BasePurgeQueue, CloudTasksRestStub): @@ -1679,7 +2192,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Call the purge queue method over HTTP. @@ -1690,8 +2203,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.queue.Queue: @@ -1707,6 +2222,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BasePurgeQueue._get_http_options() ) + request, metadata = self._interceptor.pre_purge_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BasePurgeQueue._get_transcoded_request( @@ -1725,6 +2241,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.PurgeQueue", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "PurgeQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._PurgeQueue._get_response( self._host, @@ -1746,7 +2289,29 @@ def __call__( pb_resp = queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.purge_queue", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "PurgeQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResumeQueue( @@ -1784,7 +2349,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Call the resume queue method over HTTP. @@ -1795,8 +2360,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.queue.Queue: @@ -1812,6 +2379,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseResumeQueue._get_http_options() ) + request, metadata = self._interceptor.pre_resume_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseResumeQueue._get_transcoded_request( @@ -1830,6 +2398,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.ResumeQueue", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "ResumeQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._ResumeQueue._get_response( self._host, @@ -1851,7 +2446,29 @@ def __call__( pb_resp = queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resume_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.resume_queue", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "ResumeQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunTask(_BaseCloudTasksRestTransport._BaseRunTask, CloudTasksRestStub): @@ -1887,7 +2504,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Call the run task method over HTTP. @@ -1898,8 +2515,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.task.Task: @@ -1907,6 +2526,7 @@ def __call__( """ http_options = _BaseCloudTasksRestTransport._BaseRunTask._get_http_options() + request, metadata = self._interceptor.pre_run_task(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseRunTask._get_transcoded_request( @@ -1925,6 +2545,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.RunTask", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "RunTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._RunTask._get_response( self._host, @@ -1946,7 +2593,29 @@ def __call__( pb_resp = task.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = task.Task.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.run_task", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "RunTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1984,7 +2653,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1994,8 +2663,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.policy_pb2.Policy: @@ -2080,6 +2751,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -2100,6 +2772,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._SetIamPolicy._get_response( self._host, @@ -2121,7 +2820,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2159,7 +2880,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2169,8 +2890,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -2180,6 +2903,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2196,6 +2920,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._TestIamPermissions._get_response( self._host, @@ -2217,7 +2968,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateQueue( @@ -2255,7 +3028,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Call the update queue method over HTTP. @@ -2266,8 +3039,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gct_queue.Queue: @@ -2283,6 +3058,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseUpdateQueue._get_http_options() ) + request, metadata = self._interceptor.pre_update_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseUpdateQueue._get_transcoded_request( @@ -2301,6 +3077,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.UpdateQueue", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "UpdateQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._UpdateQueue._get_response( self._host, @@ -2322,7 +3125,29 @@ def __call__( pb_resp = gct_queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksClient.update_queue", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "UpdateQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2478,7 +3303,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -2488,8 +3313,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: locations_pb2.Location: Response from GetLocation method. @@ -2498,6 +3325,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseGetLocation._get_transcoded_request( @@ -2512,6 +3340,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.GetLocation", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._GetLocation._get_response( self._host, @@ -2531,6 +3386,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2571,7 +3447,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -2581,8 +3457,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -2591,6 +3469,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseListLocations._get_transcoded_request( @@ -2605,6 +3484,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2.CloudTasksClient.ListLocations", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._ListLocations._get_response( self._host, @@ -2624,6 +3530,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2.CloudTasksAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.tasks.v2.CloudTasks", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/gapic_version.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/gapic_version.py index 6fecc94eb049..558c8aab67c5 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/gapic_version.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.17.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py index 3655735bb4b1..2c49c99b628c 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CloudTasksTransport from .transports.grpc_asyncio import CloudTasksGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class CloudTasksAsyncClient: """Cloud Tasks allows developers to manage the execution of @@ -264,6 +274,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.tasks_v2beta2.CloudTasksAsyncClient`.", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "universeDomain": getattr( + self._client._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._client._transport, "_credentials") + else { + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "credentialsType": None, + }, + ) + async def list_queues( self, request: Optional[Union[cloudtasks.ListQueuesRequest, dict]] = None, @@ -271,7 +303,7 @@ async def list_queues( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListQueuesAsyncPager: r"""Lists queues. @@ -318,8 +350,10 @@ async def sample_list_queues(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesAsyncPager: @@ -394,7 +428,7 @@ async def get_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Gets a queue. @@ -438,8 +472,10 @@ async def sample_get_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Queue: @@ -505,7 +541,7 @@ async def create_queue( queue: Optional[gct_queue.Queue] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Creates a queue. @@ -573,8 +609,10 @@ async def sample_create_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Queue: @@ -642,7 +680,7 @@ async def update_queue( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Updates a queue. @@ -716,8 +754,10 @@ async def sample_update_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Queue: @@ -786,7 +826,7 @@ async def delete_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a queue. @@ -838,8 +878,10 @@ async def sample_delete_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -891,7 +933,7 @@ async def purge_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Purges a queue by deleting all of its tasks. @@ -942,8 +984,10 @@ async def sample_purge_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Queue: @@ -1008,7 +1052,7 @@ async def pause_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Pauses the queue. @@ -1059,8 +1103,10 @@ async def sample_pause_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Queue: @@ -1125,7 +1171,7 @@ async def resume_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Resume a queue. @@ -1183,8 +1229,10 @@ async def sample_resume_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Queue: @@ -1248,7 +1296,7 @@ async def upload_queue_yaml( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Update queue list by uploading a queue.yaml file. @@ -1287,8 +1335,10 @@ async def sample_upload_queue_yaml(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -1320,7 +1370,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a [Queue][google.cloud.tasks.v2beta2.Queue]. Returns an empty @@ -1374,8 +1424,10 @@ async def sample_get_iam_policy(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -1461,7 +1513,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy for a [Queue][google.cloud.tasks.v2beta2.Queue]. Replaces any existing @@ -1519,8 +1571,10 @@ async def sample_set_iam_policy(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -1607,7 +1661,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2beta2.Queue]. If the resource does @@ -1671,8 +1725,10 @@ async def sample_test_iam_permissions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1730,7 +1786,7 @@ async def list_tasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTasksAsyncPager: r"""Lists the tasks in a queue. @@ -1784,8 +1840,10 @@ async def sample_list_tasks(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksAsyncPager: @@ -1860,7 +1918,7 @@ async def get_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Gets a task. @@ -1904,8 +1962,10 @@ async def sample_get_task(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Task: @@ -1963,7 +2023,7 @@ async def create_task( task: Optional[gct_task.Task] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_task.Task: r"""Creates a task and adds it to a queue. @@ -2064,8 +2124,10 @@ async def sample_create_task(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Task: @@ -2126,7 +2188,7 @@ async def delete_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a task. @@ -2171,8 +2233,10 @@ async def sample_delete_task(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2225,7 +2289,7 @@ async def lease_tasks( lease_duration: Optional[duration_pb2.Duration] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudtasks.LeaseTasksResponse: r"""Leases tasks from a pull queue for [lease_duration][google.cloud.tasks.v2beta2.LeaseTasksRequest.lease_duration]. @@ -2322,8 +2386,10 @@ async def sample_lease_tasks(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.LeaseTasksResponse: @@ -2387,7 +2453,7 @@ async def acknowledge_task( schedule_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Acknowledges a pull task. @@ -2456,8 +2522,10 @@ async def sample_acknowledge_task(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2513,7 +2581,7 @@ async def renew_lease( lease_duration: Optional[duration_pb2.Duration] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Renew the current lease of a pull task. @@ -2586,8 +2654,10 @@ async def sample_renew_lease(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Task: @@ -2651,7 +2721,7 @@ async def cancel_lease( schedule_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Cancel a pull task's lease. @@ -2716,8 +2786,10 @@ async def sample_cancel_lease(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Task: @@ -2778,7 +2850,7 @@ async def run_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Forces a task to run now. @@ -2854,8 +2926,10 @@ async def sample_run_task(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Task: @@ -2911,7 +2985,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2922,8 +2996,10 @@ async def get_location( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.location_pb2.Location: Location object. @@ -2964,7 +3040,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2975,8 +3051,10 @@ async def list_locations( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py index fc2fc1542447..407424f66dda 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -614,6 +624,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -676,6 +690,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.tasks_v2beta2.CloudTasksClient`.", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._transport, "_credentials") + else { + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "credentialsType": None, + }, + ) + def list_queues( self, request: Optional[Union[cloudtasks.ListQueuesRequest, dict]] = None, @@ -683,7 +720,7 @@ def list_queues( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListQueuesPager: r"""Lists queues. @@ -730,8 +767,10 @@ def sample_list_queues(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesPager: @@ -803,7 +842,7 @@ def get_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Gets a queue. @@ -847,8 +886,10 @@ def sample_get_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Queue: @@ -911,7 +952,7 @@ def create_queue( queue: Optional[gct_queue.Queue] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Creates a queue. @@ -979,8 +1020,10 @@ def sample_create_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Queue: @@ -1045,7 +1088,7 @@ def update_queue( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Updates a queue. @@ -1119,8 +1162,10 @@ def sample_update_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Queue: @@ -1186,7 +1231,7 @@ def delete_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a queue. @@ -1238,8 +1283,10 @@ def sample_delete_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1288,7 +1335,7 @@ def purge_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Purges a queue by deleting all of its tasks. @@ -1339,8 +1386,10 @@ def sample_purge_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Queue: @@ -1402,7 +1451,7 @@ def pause_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Pauses the queue. @@ -1453,8 +1502,10 @@ def sample_pause_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Queue: @@ -1516,7 +1567,7 @@ def resume_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Resume a queue. @@ -1574,8 +1625,10 @@ def sample_resume_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Queue: @@ -1636,7 +1689,7 @@ def upload_queue_yaml( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Update queue list by uploading a queue.yaml file. @@ -1675,8 +1728,10 @@ def sample_upload_queue_yaml(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -1706,7 +1761,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a [Queue][google.cloud.tasks.v2beta2.Queue]. Returns an empty @@ -1760,8 +1815,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -1848,7 +1905,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy for a [Queue][google.cloud.tasks.v2beta2.Queue]. Replaces any existing @@ -1906,8 +1963,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -1995,7 +2054,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2beta2.Queue]. If the resource does @@ -2059,8 +2118,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2119,7 +2180,7 @@ def list_tasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTasksPager: r"""Lists the tasks in a queue. @@ -2173,8 +2234,10 @@ def sample_list_tasks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksPager: @@ -2246,7 +2309,7 @@ def get_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Gets a task. @@ -2290,8 +2353,10 @@ def sample_get_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Task: @@ -2348,7 +2413,7 @@ def create_task( task: Optional[gct_task.Task] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_task.Task: r"""Creates a task and adds it to a queue. @@ -2449,8 +2514,10 @@ def sample_create_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Task: @@ -2508,7 +2575,7 @@ def delete_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a task. @@ -2553,8 +2620,10 @@ def sample_delete_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2604,7 +2673,7 @@ def lease_tasks( lease_duration: Optional[duration_pb2.Duration] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudtasks.LeaseTasksResponse: r"""Leases tasks from a pull queue for [lease_duration][google.cloud.tasks.v2beta2.LeaseTasksRequest.lease_duration]. @@ -2701,8 +2770,10 @@ def sample_lease_tasks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.LeaseTasksResponse: @@ -2763,7 +2834,7 @@ def acknowledge_task( schedule_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Acknowledges a pull task. @@ -2832,8 +2903,10 @@ def sample_acknowledge_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2886,7 +2959,7 @@ def renew_lease( lease_duration: Optional[duration_pb2.Duration] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Renew the current lease of a pull task. @@ -2959,8 +3032,10 @@ def sample_renew_lease(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Task: @@ -3021,7 +3096,7 @@ def cancel_lease( schedule_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Cancel a pull task's lease. @@ -3086,8 +3161,10 @@ def sample_cancel_lease(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Task: @@ -3145,7 +3222,7 @@ def run_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Forces a task to run now. @@ -3221,8 +3298,10 @@ def sample_run_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta2.types.Task: @@ -3290,7 +3369,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -3301,8 +3380,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.location_pb2.Location: Location object. @@ -3343,7 +3424,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -3354,8 +3435,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/pagers.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/pagers.py index 0ac27c50b603..51bb7f43aa60 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/pagers.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloudtasks.ListQueuesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloudtasks.ListQueuesRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloudtasks.ListTasksRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloudtasks.ListTasksRequest(request) diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc.py index aac007ab04e1..9085730a8770 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,7 +27,10 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.tasks_v2beta2.types import cloudtasks from google.cloud.tasks_v2beta2.types import queue @@ -34,6 +40,81 @@ from .base import DEFAULT_CLIENT_INFO, CloudTasksTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER + def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": client_call_details.method, + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + + response = continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = response.result() + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response for {client_call_details.method}.", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudTasksGrpcTransport(CloudTasksTransport): """gRPC backend transport for CloudTasks. @@ -188,7 +269,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -264,7 +350,7 @@ def list_queues( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_queues" not in self._stubs: - self._stubs["list_queues"] = self.grpc_channel.unary_unary( + self._stubs["list_queues"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/ListQueues", request_serializer=cloudtasks.ListQueuesRequest.serialize, response_deserializer=cloudtasks.ListQueuesResponse.deserialize, @@ -288,7 +374,7 @@ def get_queue(self) -> Callable[[cloudtasks.GetQueueRequest], queue.Queue]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_queue" not in self._stubs: - self._stubs["get_queue"] = self.grpc_channel.unary_unary( + self._stubs["get_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/GetQueue", request_serializer=cloudtasks.GetQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -324,7 +410,7 @@ def create_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_queue" not in self._stubs: - self._stubs["create_queue"] = self.grpc_channel.unary_unary( + self._stubs["create_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/CreateQueue", request_serializer=cloudtasks.CreateQueueRequest.serialize, response_deserializer=gct_queue.Queue.deserialize, @@ -363,7 +449,7 @@ def update_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_queue" not in self._stubs: - self._stubs["update_queue"] = self.grpc_channel.unary_unary( + self._stubs["update_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/UpdateQueue", request_serializer=cloudtasks.UpdateQueueRequest.serialize, response_deserializer=gct_queue.Queue.deserialize, @@ -400,7 +486,7 @@ def delete_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_queue" not in self._stubs: - self._stubs["delete_queue"] = self.grpc_channel.unary_unary( + self._stubs["delete_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/DeleteQueue", request_serializer=cloudtasks.DeleteQueueRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -431,7 +517,7 @@ def purge_queue(self) -> Callable[[cloudtasks.PurgeQueueRequest], queue.Queue]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_queue" not in self._stubs: - self._stubs["purge_queue"] = self.grpc_channel.unary_unary( + self._stubs["purge_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/PurgeQueue", request_serializer=cloudtasks.PurgeQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -462,7 +548,7 @@ def pause_queue(self) -> Callable[[cloudtasks.PauseQueueRequest], queue.Queue]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_queue" not in self._stubs: - self._stubs["pause_queue"] = self.grpc_channel.unary_unary( + self._stubs["pause_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/PauseQueue", request_serializer=cloudtasks.PauseQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -500,7 +586,7 @@ def resume_queue(self) -> Callable[[cloudtasks.ResumeQueueRequest], queue.Queue] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_queue" not in self._stubs: - self._stubs["resume_queue"] = self.grpc_channel.unary_unary( + self._stubs["resume_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/ResumeQueue", request_serializer=cloudtasks.ResumeQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -531,7 +617,7 @@ def upload_queue_yaml( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upload_queue_yaml" not in self._stubs: - self._stubs["upload_queue_yaml"] = self.grpc_channel.unary_unary( + self._stubs["upload_queue_yaml"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/UploadQueueYaml", request_serializer=cloudtasks.UploadQueueYamlRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -565,7 +651,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -603,7 +689,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -640,7 +726,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -675,7 +761,7 @@ def list_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tasks" not in self._stubs: - self._stubs["list_tasks"] = self.grpc_channel.unary_unary( + self._stubs["list_tasks"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/ListTasks", request_serializer=cloudtasks.ListTasksRequest.serialize, response_deserializer=cloudtasks.ListTasksResponse.deserialize, @@ -699,7 +785,7 @@ def get_task(self) -> Callable[[cloudtasks.GetTaskRequest], task.Task]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task" not in self._stubs: - self._stubs["get_task"] = self.grpc_channel.unary_unary( + self._stubs["get_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/GetTask", request_serializer=cloudtasks.GetTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -732,7 +818,7 @@ def create_task(self) -> Callable[[cloudtasks.CreateTaskRequest], gct_task.Task] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_task" not in self._stubs: - self._stubs["create_task"] = self.grpc_channel.unary_unary( + self._stubs["create_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/CreateTask", request_serializer=cloudtasks.CreateTaskRequest.serialize, response_deserializer=gct_task.Task.deserialize, @@ -760,7 +846,7 @@ def delete_task(self) -> Callable[[cloudtasks.DeleteTaskRequest], empty_pb2.Empt # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_task" not in self._stubs: - self._stubs["delete_task"] = self.grpc_channel.unary_unary( + self._stubs["delete_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/DeleteTask", request_serializer=cloudtasks.DeleteTaskRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -809,7 +895,7 @@ def lease_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "lease_tasks" not in self._stubs: - self._stubs["lease_tasks"] = self.grpc_channel.unary_unary( + self._stubs["lease_tasks"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/LeaseTasks", request_serializer=cloudtasks.LeaseTasksRequest.serialize, response_deserializer=cloudtasks.LeaseTasksResponse.deserialize, @@ -849,7 +935,7 @@ def acknowledge_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "acknowledge_task" not in self._stubs: - self._stubs["acknowledge_task"] = self.grpc_channel.unary_unary( + self._stubs["acknowledge_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/AcknowledgeTask", request_serializer=cloudtasks.AcknowledgeTaskRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -878,7 +964,7 @@ def renew_lease(self) -> Callable[[cloudtasks.RenewLeaseRequest], task.Task]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "renew_lease" not in self._stubs: - self._stubs["renew_lease"] = self.grpc_channel.unary_unary( + self._stubs["renew_lease"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/RenewLease", request_serializer=cloudtasks.RenewLeaseRequest.serialize, response_deserializer=task.Task.deserialize, @@ -909,7 +995,7 @@ def cancel_lease(self) -> Callable[[cloudtasks.CancelLeaseRequest], task.Task]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_lease" not in self._stubs: - self._stubs["cancel_lease"] = self.grpc_channel.unary_unary( + self._stubs["cancel_lease"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/CancelLease", request_serializer=cloudtasks.CancelLeaseRequest.serialize, response_deserializer=task.Task.deserialize, @@ -965,7 +1051,7 @@ def run_task(self) -> Callable[[cloudtasks.RunTaskRequest], task.Task]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_task" not in self._stubs: - self._stubs["run_task"] = self.grpc_channel.unary_unary( + self._stubs["run_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/RunTask", request_serializer=cloudtasks.RunTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -973,7 +1059,7 @@ def run_task(self) -> Callable[[cloudtasks.RunTaskRequest], task.Task]: return self._stubs["run_task"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -987,7 +1073,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1004,7 +1090,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc_asyncio.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc_asyncio.py index 4f077a8dac95..ddb5e5f4479e 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc_asyncio.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,8 +29,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.tasks_v2beta2.types import cloudtasks from google.cloud.tasks_v2beta2.types import queue @@ -38,6 +44,82 @@ from .base import DEFAULT_CLIENT_INFO, CloudTasksTransport from .grpc import CloudTasksGrpcTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientAIOInterceptor( + grpc.aio.UnaryUnaryClientInterceptor +): # pragma: NO COVER + async def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = await continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = await response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = await response + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response to rpc {client_call_details.method}.", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudTasksGrpcAsyncIOTransport(CloudTasksTransport): """gRPC AsyncIO backend transport for CloudTasks. @@ -235,10 +317,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -274,7 +359,7 @@ def list_queues( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_queues" not in self._stubs: - self._stubs["list_queues"] = self.grpc_channel.unary_unary( + self._stubs["list_queues"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/ListQueues", request_serializer=cloudtasks.ListQueuesRequest.serialize, response_deserializer=cloudtasks.ListQueuesResponse.deserialize, @@ -300,7 +385,7 @@ def get_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_queue" not in self._stubs: - self._stubs["get_queue"] = self.grpc_channel.unary_unary( + self._stubs["get_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/GetQueue", request_serializer=cloudtasks.GetQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -336,7 +421,7 @@ def create_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_queue" not in self._stubs: - self._stubs["create_queue"] = self.grpc_channel.unary_unary( + self._stubs["create_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/CreateQueue", request_serializer=cloudtasks.CreateQueueRequest.serialize, response_deserializer=gct_queue.Queue.deserialize, @@ -375,7 +460,7 @@ def update_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_queue" not in self._stubs: - self._stubs["update_queue"] = self.grpc_channel.unary_unary( + self._stubs["update_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/UpdateQueue", request_serializer=cloudtasks.UpdateQueueRequest.serialize, response_deserializer=gct_queue.Queue.deserialize, @@ -412,7 +497,7 @@ def delete_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_queue" not in self._stubs: - self._stubs["delete_queue"] = self.grpc_channel.unary_unary( + self._stubs["delete_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/DeleteQueue", request_serializer=cloudtasks.DeleteQueueRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -445,7 +530,7 @@ def purge_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_queue" not in self._stubs: - self._stubs["purge_queue"] = self.grpc_channel.unary_unary( + self._stubs["purge_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/PurgeQueue", request_serializer=cloudtasks.PurgeQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -478,7 +563,7 @@ def pause_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_queue" not in self._stubs: - self._stubs["pause_queue"] = self.grpc_channel.unary_unary( + self._stubs["pause_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/PauseQueue", request_serializer=cloudtasks.PauseQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -518,7 +603,7 @@ def resume_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_queue" not in self._stubs: - self._stubs["resume_queue"] = self.grpc_channel.unary_unary( + self._stubs["resume_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/ResumeQueue", request_serializer=cloudtasks.ResumeQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -549,7 +634,7 @@ def upload_queue_yaml( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upload_queue_yaml" not in self._stubs: - self._stubs["upload_queue_yaml"] = self.grpc_channel.unary_unary( + self._stubs["upload_queue_yaml"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/UploadQueueYaml", request_serializer=cloudtasks.UploadQueueYamlRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -583,7 +668,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -621,7 +706,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -658,7 +743,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -695,7 +780,7 @@ def list_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tasks" not in self._stubs: - self._stubs["list_tasks"] = self.grpc_channel.unary_unary( + self._stubs["list_tasks"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/ListTasks", request_serializer=cloudtasks.ListTasksRequest.serialize, response_deserializer=cloudtasks.ListTasksResponse.deserialize, @@ -719,7 +804,7 @@ def get_task(self) -> Callable[[cloudtasks.GetTaskRequest], Awaitable[task.Task] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task" not in self._stubs: - self._stubs["get_task"] = self.grpc_channel.unary_unary( + self._stubs["get_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/GetTask", request_serializer=cloudtasks.GetTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -754,7 +839,7 @@ def create_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_task" not in self._stubs: - self._stubs["create_task"] = self.grpc_channel.unary_unary( + self._stubs["create_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/CreateTask", request_serializer=cloudtasks.CreateTaskRequest.serialize, response_deserializer=gct_task.Task.deserialize, @@ -784,7 +869,7 @@ def delete_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_task" not in self._stubs: - self._stubs["delete_task"] = self.grpc_channel.unary_unary( + self._stubs["delete_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/DeleteTask", request_serializer=cloudtasks.DeleteTaskRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -835,7 +920,7 @@ def lease_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "lease_tasks" not in self._stubs: - self._stubs["lease_tasks"] = self.grpc_channel.unary_unary( + self._stubs["lease_tasks"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/LeaseTasks", request_serializer=cloudtasks.LeaseTasksRequest.serialize, response_deserializer=cloudtasks.LeaseTasksResponse.deserialize, @@ -875,7 +960,7 @@ def acknowledge_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "acknowledge_task" not in self._stubs: - self._stubs["acknowledge_task"] = self.grpc_channel.unary_unary( + self._stubs["acknowledge_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/AcknowledgeTask", request_serializer=cloudtasks.AcknowledgeTaskRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -906,7 +991,7 @@ def renew_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "renew_lease" not in self._stubs: - self._stubs["renew_lease"] = self.grpc_channel.unary_unary( + self._stubs["renew_lease"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/RenewLease", request_serializer=cloudtasks.RenewLeaseRequest.serialize, response_deserializer=task.Task.deserialize, @@ -939,7 +1024,7 @@ def cancel_lease( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_lease" not in self._stubs: - self._stubs["cancel_lease"] = self.grpc_channel.unary_unary( + self._stubs["cancel_lease"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/CancelLease", request_serializer=cloudtasks.CancelLeaseRequest.serialize, response_deserializer=task.Task.deserialize, @@ -995,7 +1080,7 @@ def run_task(self) -> Callable[[cloudtasks.RunTaskRequest], Awaitable[task.Task] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_task" not in self._stubs: - self._stubs["run_task"] = self.grpc_channel.unary_unary( + self._stubs["run_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta2.CloudTasks/RunTask", request_serializer=cloudtasks.RunTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -1208,7 +1293,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1226,7 +1311,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1243,7 +1328,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/rest.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/rest.py index 0e70bedfaad9..56aadd77da3a 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/rest.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -45,6 +45,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -229,8 +237,10 @@ def pre_upload_queue_yaml(self, request, metadata): def pre_acknowledge_task( self, request: cloudtasks.AcknowledgeTaskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.AcknowledgeTaskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudtasks.AcknowledgeTaskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for acknowledge_task Override in a subclass to manipulate the request or metadata @@ -241,8 +251,8 @@ def pre_acknowledge_task( def pre_cancel_lease( self, request: cloudtasks.CancelLeaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.CancelLeaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.CancelLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for cancel_lease Override in a subclass to manipulate the request or metadata @@ -262,8 +272,8 @@ def post_cancel_lease(self, response: task.Task) -> task.Task: def pre_create_queue( self, request: cloudtasks.CreateQueueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.CreateQueueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.CreateQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_queue Override in a subclass to manipulate the request or metadata @@ -281,8 +291,10 @@ def post_create_queue(self, response: gct_queue.Queue) -> gct_queue.Queue: return response def pre_create_task( - self, request: cloudtasks.CreateTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.CreateTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.CreateTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.CreateTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_task Override in a subclass to manipulate the request or metadata @@ -302,8 +314,8 @@ def post_create_task(self, response: gct_task.Task) -> gct_task.Task: def pre_delete_queue( self, request: cloudtasks.DeleteQueueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.DeleteQueueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.DeleteQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_queue Override in a subclass to manipulate the request or metadata @@ -312,8 +324,10 @@ def pre_delete_queue( return request, metadata def pre_delete_task( - self, request: cloudtasks.DeleteTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.DeleteTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.DeleteTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.DeleteTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_task Override in a subclass to manipulate the request or metadata @@ -324,8 +338,10 @@ def pre_delete_task( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -343,8 +359,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: return response def pre_get_queue( - self, request: cloudtasks.GetQueueRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.GetQueueRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.GetQueueRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.GetQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_queue Override in a subclass to manipulate the request or metadata @@ -362,8 +380,10 @@ def post_get_queue(self, response: queue.Queue) -> queue.Queue: return response def pre_get_task( - self, request: cloudtasks.GetTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.GetTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.GetTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.GetTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_task Override in a subclass to manipulate the request or metadata @@ -381,8 +401,10 @@ def post_get_task(self, response: task.Task) -> task.Task: return response def pre_lease_tasks( - self, request: cloudtasks.LeaseTasksRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.LeaseTasksRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.LeaseTasksRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.LeaseTasksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for lease_tasks Override in a subclass to manipulate the request or metadata @@ -402,8 +424,10 @@ def post_lease_tasks( return response def pre_list_queues( - self, request: cloudtasks.ListQueuesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.ListQueuesRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.ListQueuesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.ListQueuesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_queues Override in a subclass to manipulate the request or metadata @@ -423,8 +447,10 @@ def post_list_queues( return response def pre_list_tasks( - self, request: cloudtasks.ListTasksRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.ListTasksRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.ListTasksRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.ListTasksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tasks Override in a subclass to manipulate the request or metadata @@ -444,8 +470,10 @@ def post_list_tasks( return response def pre_pause_queue( - self, request: cloudtasks.PauseQueueRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.PauseQueueRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.PauseQueueRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.PauseQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for pause_queue Override in a subclass to manipulate the request or metadata @@ -463,8 +491,10 @@ def post_pause_queue(self, response: queue.Queue) -> queue.Queue: return response def pre_purge_queue( - self, request: cloudtasks.PurgeQueueRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.PurgeQueueRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.PurgeQueueRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.PurgeQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for purge_queue Override in a subclass to manipulate the request or metadata @@ -482,8 +512,10 @@ def post_purge_queue(self, response: queue.Queue) -> queue.Queue: return response def pre_renew_lease( - self, request: cloudtasks.RenewLeaseRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.RenewLeaseRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.RenewLeaseRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.RenewLeaseRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for renew_lease Override in a subclass to manipulate the request or metadata @@ -503,8 +535,8 @@ def post_renew_lease(self, response: task.Task) -> task.Task: def pre_resume_queue( self, request: cloudtasks.ResumeQueueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.ResumeQueueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.ResumeQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for resume_queue Override in a subclass to manipulate the request or metadata @@ -522,8 +554,10 @@ def post_resume_queue(self, response: queue.Queue) -> queue.Queue: return response def pre_run_task( - self, request: cloudtasks.RunTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.RunTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.RunTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.RunTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for run_task Override in a subclass to manipulate the request or metadata @@ -543,8 +577,10 @@ def post_run_task(self, response: task.Task) -> task.Task: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -564,8 +600,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -587,8 +626,8 @@ def post_test_iam_permissions( def pre_update_queue( self, request: cloudtasks.UpdateQueueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.UpdateQueueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.UpdateQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_queue Override in a subclass to manipulate the request or metadata @@ -608,8 +647,10 @@ def post_update_queue(self, response: gct_queue.Queue) -> gct_queue.Queue: def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -631,8 +672,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -774,7 +817,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the acknowledge task method over HTTP. @@ -785,13 +828,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseCloudTasksRestTransport._BaseAcknowledgeTask._get_http_options() ) + request, metadata = self._interceptor.pre_acknowledge_task( request, metadata ) @@ -808,6 +854,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.AcknowledgeTask", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "AcknowledgeTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._AcknowledgeTask._get_response( self._host, @@ -859,7 +932,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Call the cancel lease method over HTTP. @@ -870,8 +943,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.task.Task: @@ -881,6 +956,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseCancelLease._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_lease(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseCancelLease._get_transcoded_request( @@ -899,6 +975,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.CancelLease", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "CancelLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._CancelLease._get_response( self._host, @@ -920,7 +1023,29 @@ def __call__( pb_resp = task.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_cancel_lease(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = task.Task.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.cancel_lease", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "CancelLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateQueue( @@ -958,7 +1083,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Call the create queue method over HTTP. @@ -969,8 +1094,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gct_queue.Queue: @@ -986,6 +1113,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseCreateQueue._get_http_options() ) + request, metadata = self._interceptor.pre_create_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseCreateQueue._get_transcoded_request( @@ -1004,6 +1132,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.CreateQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "CreateQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._CreateQueue._get_response( self._host, @@ -1025,7 +1180,29 @@ def __call__( pb_resp = gct_queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.create_queue", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "CreateQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTask(_BaseCloudTasksRestTransport._BaseCreateTask, CloudTasksRestStub): @@ -1061,7 +1238,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_task.Task: r"""Call the create task method over HTTP. @@ -1072,8 +1249,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gct_task.Task: @@ -1083,6 +1262,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseCreateTask._get_http_options() ) + request, metadata = self._interceptor.pre_create_task(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseCreateTask._get_transcoded_request( @@ -1101,6 +1281,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.CreateTask", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "CreateTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._CreateTask._get_response( self._host, @@ -1122,7 +1329,29 @@ def __call__( pb_resp = gct_task.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_task.Task.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.create_task", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "CreateTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteQueue( @@ -1159,7 +1388,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete queue method over HTTP. @@ -1170,13 +1399,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseCloudTasksRestTransport._BaseDeleteQueue._get_http_options() ) + request, metadata = self._interceptor.pre_delete_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseDeleteQueue._get_transcoded_request( @@ -1191,6 +1423,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.DeleteQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "DeleteQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._DeleteQueue._get_response( self._host, @@ -1238,7 +1497,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete task method over HTTP. @@ -1249,13 +1508,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseCloudTasksRestTransport._BaseDeleteTask._get_http_options() ) + request, metadata = self._interceptor.pre_delete_task(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseDeleteTask._get_transcoded_request( @@ -1270,6 +1532,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.DeleteTask", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "DeleteTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._DeleteTask._get_response( self._host, @@ -1320,7 +1609,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1330,8 +1619,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.policy_pb2.Policy: @@ -1416,6 +1707,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -1436,6 +1728,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._GetIamPolicy._get_response( self._host, @@ -1457,7 +1776,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetQueue(_BaseCloudTasksRestTransport._BaseGetQueue, CloudTasksRestStub): @@ -1492,7 +1833,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Call the get queue method over HTTP. @@ -1503,8 +1844,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.queue.Queue: @@ -1520,6 +1863,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseGetQueue._get_http_options() ) + request, metadata = self._interceptor.pre_get_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseGetQueue._get_transcoded_request( @@ -1534,6 +1878,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.GetQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "GetQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._GetQueue._get_response( self._host, @@ -1554,7 +1925,29 @@ def __call__( pb_resp = queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.get_queue", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "GetQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTask(_BaseCloudTasksRestTransport._BaseGetTask, CloudTasksRestStub): @@ -1589,7 +1982,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Call the get task method over HTTP. @@ -1600,8 +1993,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.task.Task: @@ -1609,6 +2004,7 @@ def __call__( """ http_options = _BaseCloudTasksRestTransport._BaseGetTask._get_http_options() + request, metadata = self._interceptor.pre_get_task(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseGetTask._get_transcoded_request( @@ -1623,6 +2019,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.GetTask", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "GetTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._GetTask._get_response( self._host, @@ -1643,7 +2066,29 @@ def __call__( pb_resp = task.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = task.Task.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.get_task", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "GetTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _LeaseTasks(_BaseCloudTasksRestTransport._BaseLeaseTasks, CloudTasksRestStub): @@ -1679,7 +2124,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudtasks.LeaseTasksResponse: r"""Call the lease tasks method over HTTP. @@ -1690,8 +2135,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudtasks.LeaseTasksResponse: @@ -1703,6 +2150,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseLeaseTasks._get_http_options() ) + request, metadata = self._interceptor.pre_lease_tasks(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseLeaseTasks._get_transcoded_request( @@ -1721,6 +2169,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.LeaseTasks", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "LeaseTasks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._LeaseTasks._get_response( self._host, @@ -1742,7 +2217,29 @@ def __call__( pb_resp = cloudtasks.LeaseTasksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_lease_tasks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudtasks.LeaseTasksResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.lease_tasks", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "LeaseTasks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListQueues(_BaseCloudTasksRestTransport._BaseListQueues, CloudTasksRestStub): @@ -1777,7 +2274,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudtasks.ListQueuesResponse: r"""Call the list queues method over HTTP. @@ -1788,8 +2285,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudtasks.ListQueuesResponse: @@ -1801,6 +2300,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseListQueues._get_http_options() ) + request, metadata = self._interceptor.pre_list_queues(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseListQueues._get_transcoded_request( @@ -1815,6 +2315,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.ListQueues", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "ListQueues", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._ListQueues._get_response( self._host, @@ -1835,7 +2362,29 @@ def __call__( pb_resp = cloudtasks.ListQueuesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_queues(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudtasks.ListQueuesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.list_queues", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "ListQueues", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTasks(_BaseCloudTasksRestTransport._BaseListTasks, CloudTasksRestStub): @@ -1870,7 +2419,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudtasks.ListTasksResponse: r"""Call the list tasks method over HTTP. @@ -1881,8 +2430,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudtasks.ListTasksResponse: @@ -1894,6 +2445,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseListTasks._get_http_options() ) + request, metadata = self._interceptor.pre_list_tasks(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseListTasks._get_transcoded_request( @@ -1908,6 +2460,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.ListTasks", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "ListTasks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._ListTasks._get_response( self._host, @@ -1928,7 +2507,29 @@ def __call__( pb_resp = cloudtasks.ListTasksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tasks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudtasks.ListTasksResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.list_tasks", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "ListTasks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PauseQueue(_BaseCloudTasksRestTransport._BasePauseQueue, CloudTasksRestStub): @@ -1964,7 +2565,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Call the pause queue method over HTTP. @@ -1975,8 +2576,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.queue.Queue: @@ -1992,6 +2595,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BasePauseQueue._get_http_options() ) + request, metadata = self._interceptor.pre_pause_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BasePauseQueue._get_transcoded_request( @@ -2010,6 +2614,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.PauseQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "PauseQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._PauseQueue._get_response( self._host, @@ -2031,7 +2662,29 @@ def __call__( pb_resp = queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_pause_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.pause_queue", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "PauseQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeQueue(_BaseCloudTasksRestTransport._BasePurgeQueue, CloudTasksRestStub): @@ -2067,7 +2720,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Call the purge queue method over HTTP. @@ -2078,8 +2731,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.queue.Queue: @@ -2095,6 +2750,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BasePurgeQueue._get_http_options() ) + request, metadata = self._interceptor.pre_purge_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BasePurgeQueue._get_transcoded_request( @@ -2113,6 +2769,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.PurgeQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "PurgeQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._PurgeQueue._get_response( self._host, @@ -2134,7 +2817,29 @@ def __call__( pb_resp = queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.purge_queue", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "PurgeQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RenewLease(_BaseCloudTasksRestTransport._BaseRenewLease, CloudTasksRestStub): @@ -2170,7 +2875,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Call the renew lease method over HTTP. @@ -2181,8 +2886,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.task.Task: @@ -2192,6 +2899,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseRenewLease._get_http_options() ) + request, metadata = self._interceptor.pre_renew_lease(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseRenewLease._get_transcoded_request( @@ -2210,6 +2918,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.RenewLease", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "RenewLease", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._RenewLease._get_response( self._host, @@ -2231,7 +2966,29 @@ def __call__( pb_resp = task.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_renew_lease(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = task.Task.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.renew_lease", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "RenewLease", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResumeQueue( @@ -2269,7 +3026,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Call the resume queue method over HTTP. @@ -2280,8 +3037,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.queue.Queue: @@ -2297,6 +3056,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseResumeQueue._get_http_options() ) + request, metadata = self._interceptor.pre_resume_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseResumeQueue._get_transcoded_request( @@ -2315,6 +3075,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.ResumeQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "ResumeQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._ResumeQueue._get_response( self._host, @@ -2336,7 +3123,29 @@ def __call__( pb_resp = queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resume_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.resume_queue", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "ResumeQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunTask(_BaseCloudTasksRestTransport._BaseRunTask, CloudTasksRestStub): @@ -2372,7 +3181,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Call the run task method over HTTP. @@ -2383,8 +3192,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.task.Task: @@ -2392,6 +3203,7 @@ def __call__( """ http_options = _BaseCloudTasksRestTransport._BaseRunTask._get_http_options() + request, metadata = self._interceptor.pre_run_task(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseRunTask._get_transcoded_request( @@ -2410,6 +3222,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.RunTask", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "RunTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._RunTask._get_response( self._host, @@ -2431,7 +3270,29 @@ def __call__( pb_resp = task.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = task.Task.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.run_task", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "RunTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -2469,7 +3330,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -2479,8 +3340,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.policy_pb2.Policy: @@ -2565,6 +3428,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -2585,6 +3449,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._SetIamPolicy._get_response( self._host, @@ -2606,7 +3497,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2644,7 +3557,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2654,8 +3567,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -2665,6 +3580,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2681,6 +3597,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._TestIamPermissions._get_response( self._host, @@ -2702,7 +3645,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateQueue( @@ -2740,7 +3705,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Call the update queue method over HTTP. @@ -2751,8 +3716,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gct_queue.Queue: @@ -2768,6 +3735,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseUpdateQueue._get_http_options() ) + request, metadata = self._interceptor.pre_update_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseUpdateQueue._get_transcoded_request( @@ -2786,6 +3754,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.UpdateQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "UpdateQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._UpdateQueue._get_response( self._host, @@ -2807,7 +3802,29 @@ def __call__( pb_resp = gct_queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksClient.update_queue", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "UpdateQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UploadQueueYaml( @@ -2822,7 +3839,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): raise NotImplementedError( "Method UploadQueueYaml is not available over REST transport" @@ -3017,7 +4034,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -3027,8 +4044,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: locations_pb2.Location: Response from GetLocation method. @@ -3037,6 +4056,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseGetLocation._get_transcoded_request( @@ -3051,6 +4071,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.GetLocation", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._GetLocation._get_response( self._host, @@ -3070,6 +4117,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3110,7 +4178,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -3120,8 +4188,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -3130,6 +4200,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseListLocations._get_transcoded_request( @@ -3144,6 +4215,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta2.CloudTasksClient.ListLocations", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._ListLocations._get_response( self._host, @@ -3163,6 +4261,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta2.CloudTasksAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.tasks.v2beta2.CloudTasks", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/gapic_version.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/gapic_version.py index 6fecc94eb049..558c8aab67c5 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/gapic_version.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.17.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py index fbc775114e16..a86e7ac7e132 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CloudTasksTransport from .transports.grpc_asyncio import CloudTasksGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class CloudTasksAsyncClient: """Cloud Tasks allows developers to manage the execution of @@ -264,6 +274,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.tasks_v2beta3.CloudTasksAsyncClient`.", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "universeDomain": getattr( + self._client._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._client._transport, "_credentials") + else { + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "credentialsType": None, + }, + ) + async def list_queues( self, request: Optional[Union[cloudtasks.ListQueuesRequest, dict]] = None, @@ -271,7 +303,7 @@ async def list_queues( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListQueuesAsyncPager: r"""Lists queues. @@ -318,8 +350,10 @@ async def sample_list_queues(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListQueuesAsyncPager: @@ -394,7 +428,7 @@ async def get_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Gets a queue. @@ -438,8 +472,10 @@ async def sample_get_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Queue: @@ -505,7 +541,7 @@ async def create_queue( queue: Optional[gct_queue.Queue] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Creates a queue. @@ -573,8 +609,10 @@ async def sample_create_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Queue: @@ -642,7 +680,7 @@ async def update_queue( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Updates a queue. @@ -716,8 +754,10 @@ async def sample_update_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Queue: @@ -786,7 +826,7 @@ async def delete_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a queue. @@ -838,8 +878,10 @@ async def sample_delete_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -891,7 +933,7 @@ async def purge_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Purges a queue by deleting all of its tasks. @@ -942,8 +984,10 @@ async def sample_purge_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Queue: @@ -1008,7 +1052,7 @@ async def pause_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Pauses the queue. @@ -1059,8 +1103,10 @@ async def sample_pause_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Queue: @@ -1125,7 +1171,7 @@ async def resume_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Resume a queue. @@ -1183,8 +1229,10 @@ async def sample_resume_queue(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Queue: @@ -1249,7 +1297,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a [Queue][google.cloud.tasks.v2beta3.Queue]. Returns an empty @@ -1303,8 +1351,10 @@ async def sample_get_iam_policy(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -1390,7 +1440,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy for a [Queue][google.cloud.tasks.v2beta3.Queue]. Replaces any existing @@ -1448,8 +1498,10 @@ async def sample_set_iam_policy(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -1536,7 +1588,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2beta3.Queue]. If the resource does @@ -1600,8 +1652,10 @@ async def sample_test_iam_permissions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -1659,7 +1713,7 @@ async def list_tasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTasksAsyncPager: r"""Lists the tasks in a queue. @@ -1713,8 +1767,10 @@ async def sample_list_tasks(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListTasksAsyncPager: @@ -1789,7 +1845,7 @@ async def get_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Gets a task. @@ -1833,8 +1889,10 @@ async def sample_get_task(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Task: @@ -1892,7 +1950,7 @@ async def create_task( task: Optional[gct_task.Task] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_task.Task: r"""Creates a task and adds it to a queue. @@ -1989,8 +2047,10 @@ async def sample_create_task(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Task: @@ -2051,7 +2111,7 @@ async def delete_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a task. @@ -2096,8 +2156,10 @@ async def sample_delete_task(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2149,7 +2211,7 @@ async def run_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Forces a task to run now. @@ -2220,8 +2282,10 @@ async def sample_run_task(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Task: @@ -2277,7 +2341,7 @@ async def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2288,8 +2352,10 @@ async def get_location( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.location_pb2.Location: Location object. @@ -2330,7 +2396,7 @@ async def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2341,8 +2407,10 @@ async def list_locations( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py index bcbb2b59eb49..0891ac4b9c63 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -614,6 +624,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -676,6 +690,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.tasks_v2beta3.CloudTasksClient`.", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._transport, "_credentials") + else { + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "credentialsType": None, + }, + ) + def list_queues( self, request: Optional[Union[cloudtasks.ListQueuesRequest, dict]] = None, @@ -683,7 +720,7 @@ def list_queues( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListQueuesPager: r"""Lists queues. @@ -730,8 +767,10 @@ def sample_list_queues(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListQueuesPager: @@ -803,7 +842,7 @@ def get_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Gets a queue. @@ -847,8 +886,10 @@ def sample_get_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Queue: @@ -911,7 +952,7 @@ def create_queue( queue: Optional[gct_queue.Queue] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Creates a queue. @@ -979,8 +1020,10 @@ def sample_create_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Queue: @@ -1045,7 +1088,7 @@ def update_queue( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Updates a queue. @@ -1119,8 +1162,10 @@ def sample_update_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Queue: @@ -1186,7 +1231,7 @@ def delete_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a queue. @@ -1238,8 +1283,10 @@ def sample_delete_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1288,7 +1335,7 @@ def purge_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Purges a queue by deleting all of its tasks. @@ -1339,8 +1386,10 @@ def sample_purge_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Queue: @@ -1402,7 +1451,7 @@ def pause_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Pauses the queue. @@ -1453,8 +1502,10 @@ def sample_pause_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Queue: @@ -1516,7 +1567,7 @@ def resume_queue( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Resume a queue. @@ -1574,8 +1625,10 @@ def sample_resume_queue(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Queue: @@ -1637,7 +1690,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a [Queue][google.cloud.tasks.v2beta3.Queue]. Returns an empty @@ -1691,8 +1744,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -1779,7 +1834,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy for a [Queue][google.cloud.tasks.v2beta3.Queue]. Replaces any existing @@ -1837,8 +1892,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -1926,7 +1983,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2beta3.Queue]. If the resource does @@ -1990,8 +2047,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2050,7 +2109,7 @@ def list_tasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTasksPager: r"""Lists the tasks in a queue. @@ -2104,8 +2163,10 @@ def sample_list_tasks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListTasksPager: @@ -2177,7 +2238,7 @@ def get_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Gets a task. @@ -2221,8 +2282,10 @@ def sample_get_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Task: @@ -2279,7 +2342,7 @@ def create_task( task: Optional[gct_task.Task] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_task.Task: r"""Creates a task and adds it to a queue. @@ -2376,8 +2439,10 @@ def sample_create_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Task: @@ -2435,7 +2500,7 @@ def delete_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a task. @@ -2480,8 +2545,10 @@ def sample_delete_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2530,7 +2597,7 @@ def run_task( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Forces a task to run now. @@ -2601,8 +2668,10 @@ def sample_run_task(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.tasks_v2beta3.types.Task: @@ -2670,7 +2739,7 @@ def get_location( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Gets information about a location. @@ -2681,8 +2750,10 @@ def get_location( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.location_pb2.Location: Location object. @@ -2723,7 +2794,7 @@ def list_locations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Lists information about the supported locations for this service. @@ -2734,8 +2805,10 @@ def list_locations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.location_pb2.ListLocationsResponse: Response message for ``ListLocations`` method. diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/pagers.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/pagers.py index e5d43ca8507a..9edb2b466cbe 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/pagers.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloudtasks.ListQueuesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloudtasks.ListQueuesRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloudtasks.ListTasksRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloudtasks.ListTasksRequest(request) diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc.py index 8d352fc9b2ef..d8db6d26c761 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,7 +27,10 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.tasks_v2beta3.types import cloudtasks from google.cloud.tasks_v2beta3.types import queue @@ -34,6 +40,81 @@ from .base import DEFAULT_CLIENT_INFO, CloudTasksTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER + def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": client_call_details.method, + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + + response = continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = response.result() + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response for {client_call_details.method}.", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudTasksGrpcTransport(CloudTasksTransport): """gRPC backend transport for CloudTasks. @@ -188,7 +269,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -264,7 +350,7 @@ def list_queues( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_queues" not in self._stubs: - self._stubs["list_queues"] = self.grpc_channel.unary_unary( + self._stubs["list_queues"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/ListQueues", request_serializer=cloudtasks.ListQueuesRequest.serialize, response_deserializer=cloudtasks.ListQueuesResponse.deserialize, @@ -288,7 +374,7 @@ def get_queue(self) -> Callable[[cloudtasks.GetQueueRequest], queue.Queue]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_queue" not in self._stubs: - self._stubs["get_queue"] = self.grpc_channel.unary_unary( + self._stubs["get_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/GetQueue", request_serializer=cloudtasks.GetQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -324,7 +410,7 @@ def create_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_queue" not in self._stubs: - self._stubs["create_queue"] = self.grpc_channel.unary_unary( + self._stubs["create_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/CreateQueue", request_serializer=cloudtasks.CreateQueueRequest.serialize, response_deserializer=gct_queue.Queue.deserialize, @@ -363,7 +449,7 @@ def update_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_queue" not in self._stubs: - self._stubs["update_queue"] = self.grpc_channel.unary_unary( + self._stubs["update_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/UpdateQueue", request_serializer=cloudtasks.UpdateQueueRequest.serialize, response_deserializer=gct_queue.Queue.deserialize, @@ -400,7 +486,7 @@ def delete_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_queue" not in self._stubs: - self._stubs["delete_queue"] = self.grpc_channel.unary_unary( + self._stubs["delete_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/DeleteQueue", request_serializer=cloudtasks.DeleteQueueRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -431,7 +517,7 @@ def purge_queue(self) -> Callable[[cloudtasks.PurgeQueueRequest], queue.Queue]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_queue" not in self._stubs: - self._stubs["purge_queue"] = self.grpc_channel.unary_unary( + self._stubs["purge_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/PurgeQueue", request_serializer=cloudtasks.PurgeQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -462,7 +548,7 @@ def pause_queue(self) -> Callable[[cloudtasks.PauseQueueRequest], queue.Queue]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_queue" not in self._stubs: - self._stubs["pause_queue"] = self.grpc_channel.unary_unary( + self._stubs["pause_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/PauseQueue", request_serializer=cloudtasks.PauseQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -500,7 +586,7 @@ def resume_queue(self) -> Callable[[cloudtasks.ResumeQueueRequest], queue.Queue] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_queue" not in self._stubs: - self._stubs["resume_queue"] = self.grpc_channel.unary_unary( + self._stubs["resume_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/ResumeQueue", request_serializer=cloudtasks.ResumeQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -534,7 +620,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -572,7 +658,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -609,7 +695,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -644,7 +730,7 @@ def list_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tasks" not in self._stubs: - self._stubs["list_tasks"] = self.grpc_channel.unary_unary( + self._stubs["list_tasks"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/ListTasks", request_serializer=cloudtasks.ListTasksRequest.serialize, response_deserializer=cloudtasks.ListTasksResponse.deserialize, @@ -668,7 +754,7 @@ def get_task(self) -> Callable[[cloudtasks.GetTaskRequest], task.Task]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task" not in self._stubs: - self._stubs["get_task"] = self.grpc_channel.unary_unary( + self._stubs["get_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/GetTask", request_serializer=cloudtasks.GetTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -697,7 +783,7 @@ def create_task(self) -> Callable[[cloudtasks.CreateTaskRequest], gct_task.Task] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_task" not in self._stubs: - self._stubs["create_task"] = self.grpc_channel.unary_unary( + self._stubs["create_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/CreateTask", request_serializer=cloudtasks.CreateTaskRequest.serialize, response_deserializer=gct_task.Task.deserialize, @@ -725,7 +811,7 @@ def delete_task(self) -> Callable[[cloudtasks.DeleteTaskRequest], empty_pb2.Empt # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_task" not in self._stubs: - self._stubs["delete_task"] = self.grpc_channel.unary_unary( + self._stubs["delete_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/DeleteTask", request_serializer=cloudtasks.DeleteTaskRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -776,7 +862,7 @@ def run_task(self) -> Callable[[cloudtasks.RunTaskRequest], task.Task]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_task" not in self._stubs: - self._stubs["run_task"] = self.grpc_channel.unary_unary( + self._stubs["run_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/RunTask", request_serializer=cloudtasks.RunTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -784,7 +870,7 @@ def run_task(self) -> Callable[[cloudtasks.RunTaskRequest], task.Task]: return self._stubs["run_task"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -798,7 +884,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -815,7 +901,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc_asyncio.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc_asyncio.py index 8d197e90c9e6..6317fb62105b 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc_asyncio.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,8 +29,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.tasks_v2beta3.types import cloudtasks from google.cloud.tasks_v2beta3.types import queue @@ -38,6 +44,82 @@ from .base import DEFAULT_CLIENT_INFO, CloudTasksTransport from .grpc import CloudTasksGrpcTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientAIOInterceptor( + grpc.aio.UnaryUnaryClientInterceptor +): # pragma: NO COVER + async def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = await continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = await response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = await response + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response to rpc {client_call_details.method}.", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudTasksGrpcAsyncIOTransport(CloudTasksTransport): """gRPC AsyncIO backend transport for CloudTasks. @@ -235,10 +317,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -274,7 +359,7 @@ def list_queues( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_queues" not in self._stubs: - self._stubs["list_queues"] = self.grpc_channel.unary_unary( + self._stubs["list_queues"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/ListQueues", request_serializer=cloudtasks.ListQueuesRequest.serialize, response_deserializer=cloudtasks.ListQueuesResponse.deserialize, @@ -300,7 +385,7 @@ def get_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_queue" not in self._stubs: - self._stubs["get_queue"] = self.grpc_channel.unary_unary( + self._stubs["get_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/GetQueue", request_serializer=cloudtasks.GetQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -336,7 +421,7 @@ def create_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_queue" not in self._stubs: - self._stubs["create_queue"] = self.grpc_channel.unary_unary( + self._stubs["create_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/CreateQueue", request_serializer=cloudtasks.CreateQueueRequest.serialize, response_deserializer=gct_queue.Queue.deserialize, @@ -375,7 +460,7 @@ def update_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_queue" not in self._stubs: - self._stubs["update_queue"] = self.grpc_channel.unary_unary( + self._stubs["update_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/UpdateQueue", request_serializer=cloudtasks.UpdateQueueRequest.serialize, response_deserializer=gct_queue.Queue.deserialize, @@ -412,7 +497,7 @@ def delete_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_queue" not in self._stubs: - self._stubs["delete_queue"] = self.grpc_channel.unary_unary( + self._stubs["delete_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/DeleteQueue", request_serializer=cloudtasks.DeleteQueueRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -445,7 +530,7 @@ def purge_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "purge_queue" not in self._stubs: - self._stubs["purge_queue"] = self.grpc_channel.unary_unary( + self._stubs["purge_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/PurgeQueue", request_serializer=cloudtasks.PurgeQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -478,7 +563,7 @@ def pause_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "pause_queue" not in self._stubs: - self._stubs["pause_queue"] = self.grpc_channel.unary_unary( + self._stubs["pause_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/PauseQueue", request_serializer=cloudtasks.PauseQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -518,7 +603,7 @@ def resume_queue( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resume_queue" not in self._stubs: - self._stubs["resume_queue"] = self.grpc_channel.unary_unary( + self._stubs["resume_queue"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/ResumeQueue", request_serializer=cloudtasks.ResumeQueueRequest.serialize, response_deserializer=queue.Queue.deserialize, @@ -552,7 +637,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -590,7 +675,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -627,7 +712,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -664,7 +749,7 @@ def list_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tasks" not in self._stubs: - self._stubs["list_tasks"] = self.grpc_channel.unary_unary( + self._stubs["list_tasks"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/ListTasks", request_serializer=cloudtasks.ListTasksRequest.serialize, response_deserializer=cloudtasks.ListTasksResponse.deserialize, @@ -688,7 +773,7 @@ def get_task(self) -> Callable[[cloudtasks.GetTaskRequest], Awaitable[task.Task] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_task" not in self._stubs: - self._stubs["get_task"] = self.grpc_channel.unary_unary( + self._stubs["get_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/GetTask", request_serializer=cloudtasks.GetTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -719,7 +804,7 @@ def create_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_task" not in self._stubs: - self._stubs["create_task"] = self.grpc_channel.unary_unary( + self._stubs["create_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/CreateTask", request_serializer=cloudtasks.CreateTaskRequest.serialize, response_deserializer=gct_task.Task.deserialize, @@ -749,7 +834,7 @@ def delete_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_task" not in self._stubs: - self._stubs["delete_task"] = self.grpc_channel.unary_unary( + self._stubs["delete_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/DeleteTask", request_serializer=cloudtasks.DeleteTaskRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -800,7 +885,7 @@ def run_task(self) -> Callable[[cloudtasks.RunTaskRequest], Awaitable[task.Task] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_task" not in self._stubs: - self._stubs["run_task"] = self.grpc_channel.unary_unary( + self._stubs["run_task"] = self._logged_channel.unary_unary( "/google.cloud.tasks.v2beta3.CloudTasks/RunTask", request_serializer=cloudtasks.RunTaskRequest.serialize, response_deserializer=task.Task.deserialize, @@ -988,7 +1073,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -1006,7 +1091,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -1023,7 +1108,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/rest.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/rest.py index b3529e3be2ad..2a5f9869222d 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/rest.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -45,6 +45,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -197,8 +205,8 @@ def post_update_queue(self, response): def pre_create_queue( self, request: cloudtasks.CreateQueueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.CreateQueueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.CreateQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_queue Override in a subclass to manipulate the request or metadata @@ -216,8 +224,10 @@ def post_create_queue(self, response: gct_queue.Queue) -> gct_queue.Queue: return response def pre_create_task( - self, request: cloudtasks.CreateTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.CreateTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.CreateTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.CreateTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_task Override in a subclass to manipulate the request or metadata @@ -237,8 +247,8 @@ def post_create_task(self, response: gct_task.Task) -> gct_task.Task: def pre_delete_queue( self, request: cloudtasks.DeleteQueueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.DeleteQueueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.DeleteQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_queue Override in a subclass to manipulate the request or metadata @@ -247,8 +257,10 @@ def pre_delete_queue( return request, metadata def pre_delete_task( - self, request: cloudtasks.DeleteTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.DeleteTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.DeleteTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.DeleteTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_task Override in a subclass to manipulate the request or metadata @@ -259,8 +271,10 @@ def pre_delete_task( def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -278,8 +292,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: return response def pre_get_queue( - self, request: cloudtasks.GetQueueRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.GetQueueRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.GetQueueRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.GetQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_queue Override in a subclass to manipulate the request or metadata @@ -297,8 +313,10 @@ def post_get_queue(self, response: queue.Queue) -> queue.Queue: return response def pre_get_task( - self, request: cloudtasks.GetTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.GetTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.GetTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.GetTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_task Override in a subclass to manipulate the request or metadata @@ -316,8 +334,10 @@ def post_get_task(self, response: task.Task) -> task.Task: return response def pre_list_queues( - self, request: cloudtasks.ListQueuesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.ListQueuesRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.ListQueuesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.ListQueuesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_queues Override in a subclass to manipulate the request or metadata @@ -337,8 +357,10 @@ def post_list_queues( return response def pre_list_tasks( - self, request: cloudtasks.ListTasksRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.ListTasksRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.ListTasksRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.ListTasksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tasks Override in a subclass to manipulate the request or metadata @@ -358,8 +380,10 @@ def post_list_tasks( return response def pre_pause_queue( - self, request: cloudtasks.PauseQueueRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.PauseQueueRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.PauseQueueRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.PauseQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for pause_queue Override in a subclass to manipulate the request or metadata @@ -377,8 +401,10 @@ def post_pause_queue(self, response: queue.Queue) -> queue.Queue: return response def pre_purge_queue( - self, request: cloudtasks.PurgeQueueRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.PurgeQueueRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.PurgeQueueRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.PurgeQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for purge_queue Override in a subclass to manipulate the request or metadata @@ -398,8 +424,8 @@ def post_purge_queue(self, response: queue.Queue) -> queue.Queue: def pre_resume_queue( self, request: cloudtasks.ResumeQueueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.ResumeQueueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.ResumeQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for resume_queue Override in a subclass to manipulate the request or metadata @@ -417,8 +443,10 @@ def post_resume_queue(self, response: queue.Queue) -> queue.Queue: return response def pre_run_task( - self, request: cloudtasks.RunTaskRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudtasks.RunTaskRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudtasks.RunTaskRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.RunTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for run_task Override in a subclass to manipulate the request or metadata @@ -438,8 +466,10 @@ def post_run_task(self, response: task.Task) -> task.Task: def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -459,8 +489,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -482,8 +515,8 @@ def post_test_iam_permissions( def pre_update_queue( self, request: cloudtasks.UpdateQueueRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudtasks.UpdateQueueRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudtasks.UpdateQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_queue Override in a subclass to manipulate the request or metadata @@ -503,8 +536,10 @@ def post_update_queue(self, response: gct_queue.Queue) -> gct_queue.Queue: def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -526,8 +561,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -669,7 +706,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Call the create queue method over HTTP. @@ -680,8 +717,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gct_queue.Queue: @@ -697,6 +736,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseCreateQueue._get_http_options() ) + request, metadata = self._interceptor.pre_create_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseCreateQueue._get_transcoded_request( @@ -715,6 +755,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.CreateQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "CreateQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._CreateQueue._get_response( self._host, @@ -736,7 +803,29 @@ def __call__( pb_resp = gct_queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.create_queue", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "CreateQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTask(_BaseCloudTasksRestTransport._BaseCreateTask, CloudTasksRestStub): @@ -772,7 +861,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_task.Task: r"""Call the create task method over HTTP. @@ -783,8 +872,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gct_task.Task: @@ -794,6 +885,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseCreateTask._get_http_options() ) + request, metadata = self._interceptor.pre_create_task(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseCreateTask._get_transcoded_request( @@ -812,6 +904,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.CreateTask", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "CreateTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._CreateTask._get_response( self._host, @@ -833,7 +952,29 @@ def __call__( pb_resp = gct_task.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_task.Task.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.create_task", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "CreateTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteQueue( @@ -870,7 +1011,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete queue method over HTTP. @@ -881,13 +1022,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseCloudTasksRestTransport._BaseDeleteQueue._get_http_options() ) + request, metadata = self._interceptor.pre_delete_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseDeleteQueue._get_transcoded_request( @@ -902,6 +1046,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.DeleteQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "DeleteQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._DeleteQueue._get_response( self._host, @@ -949,7 +1120,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete task method over HTTP. @@ -960,13 +1131,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseCloudTasksRestTransport._BaseDeleteTask._get_http_options() ) + request, metadata = self._interceptor.pre_delete_task(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseDeleteTask._get_transcoded_request( @@ -981,6 +1155,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.DeleteTask", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "DeleteTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._DeleteTask._get_response( self._host, @@ -1031,7 +1232,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1041,8 +1242,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.policy_pb2.Policy: @@ -1127,6 +1330,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -1147,6 +1351,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._GetIamPolicy._get_response( self._host, @@ -1168,7 +1399,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetQueue(_BaseCloudTasksRestTransport._BaseGetQueue, CloudTasksRestStub): @@ -1203,7 +1456,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Call the get queue method over HTTP. @@ -1214,8 +1467,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.queue.Queue: @@ -1231,6 +1486,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseGetQueue._get_http_options() ) + request, metadata = self._interceptor.pre_get_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseGetQueue._get_transcoded_request( @@ -1245,6 +1501,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.GetQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "GetQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._GetQueue._get_response( self._host, @@ -1265,7 +1548,29 @@ def __call__( pb_resp = queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.get_queue", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "GetQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTask(_BaseCloudTasksRestTransport._BaseGetTask, CloudTasksRestStub): @@ -1300,7 +1605,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Call the get task method over HTTP. @@ -1311,8 +1616,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.task.Task: @@ -1320,6 +1627,7 @@ def __call__( """ http_options = _BaseCloudTasksRestTransport._BaseGetTask._get_http_options() + request, metadata = self._interceptor.pre_get_task(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseGetTask._get_transcoded_request( @@ -1334,6 +1642,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.GetTask", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "GetTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._GetTask._get_response( self._host, @@ -1354,7 +1689,29 @@ def __call__( pb_resp = task.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = task.Task.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.get_task", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "GetTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListQueues(_BaseCloudTasksRestTransport._BaseListQueues, CloudTasksRestStub): @@ -1389,7 +1746,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudtasks.ListQueuesResponse: r"""Call the list queues method over HTTP. @@ -1400,8 +1757,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudtasks.ListQueuesResponse: @@ -1413,6 +1772,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseListQueues._get_http_options() ) + request, metadata = self._interceptor.pre_list_queues(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseListQueues._get_transcoded_request( @@ -1427,6 +1787,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.ListQueues", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "ListQueues", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._ListQueues._get_response( self._host, @@ -1447,7 +1834,29 @@ def __call__( pb_resp = cloudtasks.ListQueuesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_queues(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudtasks.ListQueuesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.list_queues", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "ListQueues", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTasks(_BaseCloudTasksRestTransport._BaseListTasks, CloudTasksRestStub): @@ -1482,7 +1891,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudtasks.ListTasksResponse: r"""Call the list tasks method over HTTP. @@ -1493,8 +1902,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudtasks.ListTasksResponse: @@ -1506,6 +1917,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseListTasks._get_http_options() ) + request, metadata = self._interceptor.pre_list_tasks(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseListTasks._get_transcoded_request( @@ -1520,6 +1932,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.ListTasks", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "ListTasks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._ListTasks._get_response( self._host, @@ -1540,7 +1979,29 @@ def __call__( pb_resp = cloudtasks.ListTasksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tasks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudtasks.ListTasksResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.list_tasks", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "ListTasks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PauseQueue(_BaseCloudTasksRestTransport._BasePauseQueue, CloudTasksRestStub): @@ -1576,7 +2037,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Call the pause queue method over HTTP. @@ -1587,8 +2048,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.queue.Queue: @@ -1604,6 +2067,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BasePauseQueue._get_http_options() ) + request, metadata = self._interceptor.pre_pause_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BasePauseQueue._get_transcoded_request( @@ -1622,6 +2086,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.PauseQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "PauseQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._PauseQueue._get_response( self._host, @@ -1643,7 +2134,29 @@ def __call__( pb_resp = queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_pause_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.pause_queue", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "PauseQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PurgeQueue(_BaseCloudTasksRestTransport._BasePurgeQueue, CloudTasksRestStub): @@ -1679,7 +2192,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Call the purge queue method over HTTP. @@ -1690,8 +2203,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.queue.Queue: @@ -1707,6 +2222,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BasePurgeQueue._get_http_options() ) + request, metadata = self._interceptor.pre_purge_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BasePurgeQueue._get_transcoded_request( @@ -1725,6 +2241,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.PurgeQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "PurgeQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._PurgeQueue._get_response( self._host, @@ -1746,7 +2289,29 @@ def __call__( pb_resp = queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_purge_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.purge_queue", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "PurgeQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResumeQueue( @@ -1784,7 +2349,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> queue.Queue: r"""Call the resume queue method over HTTP. @@ -1795,8 +2360,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.queue.Queue: @@ -1812,6 +2379,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseResumeQueue._get_http_options() ) + request, metadata = self._interceptor.pre_resume_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseResumeQueue._get_transcoded_request( @@ -1830,6 +2398,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.ResumeQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "ResumeQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._ResumeQueue._get_response( self._host, @@ -1851,7 +2446,29 @@ def __call__( pb_resp = queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resume_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.resume_queue", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "ResumeQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunTask(_BaseCloudTasksRestTransport._BaseRunTask, CloudTasksRestStub): @@ -1887,7 +2504,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> task.Task: r"""Call the run task method over HTTP. @@ -1898,8 +2515,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.task.Task: @@ -1907,6 +2526,7 @@ def __call__( """ http_options = _BaseCloudTasksRestTransport._BaseRunTask._get_http_options() + request, metadata = self._interceptor.pre_run_task(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseRunTask._get_transcoded_request( @@ -1925,6 +2545,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.RunTask", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "RunTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._RunTask._get_response( self._host, @@ -1946,7 +2593,29 @@ def __call__( pb_resp = task.Task.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = task.Task.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.run_task", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "RunTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1984,7 +2653,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1994,8 +2663,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.policy_pb2.Policy: @@ -2080,6 +2751,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -2100,6 +2772,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._SetIamPolicy._get_response( self._host, @@ -2121,7 +2820,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -2159,7 +2880,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -2169,8 +2890,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -2180,6 +2903,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2196,6 +2920,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._TestIamPermissions._get_response( self._host, @@ -2217,7 +2968,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateQueue( @@ -2255,7 +3028,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gct_queue.Queue: r"""Call the update queue method over HTTP. @@ -2266,8 +3039,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gct_queue.Queue: @@ -2283,6 +3058,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseUpdateQueue._get_http_options() ) + request, metadata = self._interceptor.pre_update_queue(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseUpdateQueue._get_transcoded_request( @@ -2301,6 +3077,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.UpdateQueue", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "UpdateQueue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._UpdateQueue._get_response( self._host, @@ -2322,7 +3125,29 @@ def __call__( pb_resp = gct_queue.Queue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_queue(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gct_queue.Queue.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksClient.update_queue", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "UpdateQueue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2478,7 +3303,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -2488,8 +3313,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: locations_pb2.Location: Response from GetLocation method. @@ -2498,6 +3325,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseGetLocation._get_transcoded_request( @@ -2512,6 +3340,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.GetLocation", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._GetLocation._get_response( self._host, @@ -2531,6 +3386,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2571,7 +3447,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -2581,8 +3457,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -2591,6 +3469,7 @@ def __call__( http_options = ( _BaseCloudTasksRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseCloudTasksRestTransport._BaseListLocations._get_transcoded_request( @@ -2605,6 +3484,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.tasks_v2beta3.CloudTasksClient.ListLocations", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudTasksRestTransport._ListLocations._get_response( self._host, @@ -2624,6 +3530,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.tasks_v2beta3.CloudTasksAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.tasks.v2beta3.CloudTasks", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2.json b/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2.json index 589639a9caab..a40f846fdcce 100644 --- a/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2.json +++ b/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tasks", - "version": "2.17.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Queue", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Queue", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Task", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Task", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_queue" @@ -462,7 +462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_queue" @@ -540,7 +540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_task" @@ -617,7 +617,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_task" @@ -695,7 +695,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -775,7 +775,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -856,7 +856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Queue", @@ -936,7 +936,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Queue", @@ -1017,7 +1017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Task", @@ -1097,7 +1097,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Task", @@ -1178,7 +1178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.services.cloud_tasks.pagers.ListQueuesAsyncPager", @@ -1258,7 +1258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.services.cloud_tasks.pagers.ListQueuesPager", @@ -1339,7 +1339,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.services.cloud_tasks.pagers.ListTasksAsyncPager", @@ -1419,7 +1419,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.services.cloud_tasks.pagers.ListTasksPager", @@ -1500,7 +1500,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Queue", @@ -1580,7 +1580,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Queue", @@ -1661,7 +1661,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Queue", @@ -1741,7 +1741,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Queue", @@ -1822,7 +1822,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Queue", @@ -1902,7 +1902,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Queue", @@ -1983,7 +1983,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Task", @@ -2063,7 +2063,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Task", @@ -2144,7 +2144,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2224,7 +2224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2309,7 +2309,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2393,7 +2393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2478,7 +2478,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Queue", @@ -2562,7 +2562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2.types.Queue", diff --git a/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta2.json b/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta2.json index d1c852cbaea0..2b3fcc2324d1 100644 --- a/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta2.json +++ b/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tasks", - "version": "2.17.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "acknowledge_task" @@ -132,7 +132,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "acknowledge_task" @@ -214,7 +214,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Task", @@ -298,7 +298,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Task", @@ -383,7 +383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Queue", @@ -467,7 +467,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Queue", @@ -552,7 +552,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Task", @@ -636,7 +636,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Task", @@ -717,7 +717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_queue" @@ -794,7 +794,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_queue" @@ -872,7 +872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_task" @@ -949,7 +949,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_task" @@ -1027,7 +1027,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1107,7 +1107,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1188,7 +1188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Queue", @@ -1268,7 +1268,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Queue", @@ -1349,7 +1349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Task", @@ -1429,7 +1429,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Task", @@ -1514,7 +1514,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.LeaseTasksResponse", @@ -1598,7 +1598,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.LeaseTasksResponse", @@ -1679,7 +1679,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesAsyncPager", @@ -1759,7 +1759,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesPager", @@ -1840,7 +1840,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksAsyncPager", @@ -1920,7 +1920,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksPager", @@ -2001,7 +2001,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Queue", @@ -2081,7 +2081,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Queue", @@ -2162,7 +2162,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Queue", @@ -2242,7 +2242,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Queue", @@ -2331,7 +2331,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Task", @@ -2419,7 +2419,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Task", @@ -2500,7 +2500,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Queue", @@ -2580,7 +2580,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Queue", @@ -2661,7 +2661,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Task", @@ -2741,7 +2741,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Task", @@ -2822,7 +2822,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2902,7 +2902,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2987,7 +2987,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -3071,7 +3071,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -3156,7 +3156,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Queue", @@ -3240,7 +3240,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta2.types.Queue", @@ -3317,7 +3317,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "upload_queue_yaml" @@ -3390,7 +3390,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "upload_queue_yaml" diff --git a/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta3.json b/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta3.json index 974539512c99..c3812fadd698 100644 --- a/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta3.json +++ b/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta3.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tasks", - "version": "2.17.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Queue", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Queue", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Task", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Task", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_queue" @@ -462,7 +462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_queue" @@ -540,7 +540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_task" @@ -617,7 +617,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_task" @@ -695,7 +695,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -775,7 +775,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -856,7 +856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Queue", @@ -936,7 +936,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Queue", @@ -1017,7 +1017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Task", @@ -1097,7 +1097,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Task", @@ -1178,7 +1178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListQueuesAsyncPager", @@ -1258,7 +1258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListQueuesPager", @@ -1339,7 +1339,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListTasksAsyncPager", @@ -1419,7 +1419,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListTasksPager", @@ -1500,7 +1500,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Queue", @@ -1580,7 +1580,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Queue", @@ -1661,7 +1661,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Queue", @@ -1741,7 +1741,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Queue", @@ -1822,7 +1822,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Queue", @@ -1902,7 +1902,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Queue", @@ -1983,7 +1983,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Task", @@ -2063,7 +2063,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Task", @@ -2144,7 +2144,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2224,7 +2224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2309,7 +2309,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2393,7 +2393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2478,7 +2478,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Queue", @@ -2562,7 +2562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.tasks_v2beta3.types.Queue", diff --git a/packages/google-cloud-tasks/tasks-v2beta2-py.tar.gz b/packages/google-cloud-tasks/tasks-v2beta2-py.tar.gz new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2/test_cloud_tasks.py b/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2/test_cloud_tasks.py index e9006645cc87..22ddb302807d 100644 --- a/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2/test_cloud_tasks.py +++ b/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2/test_cloud_tasks.py @@ -6805,6 +6805,7 @@ def test_list_queues_rest_required_fields(request_type=cloudtasks.ListQueuesRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_queues(request) @@ -6859,6 +6860,7 @@ def test_list_queues_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_queues(**mock_args) @@ -7048,6 +7050,7 @@ def test_get_queue_rest_required_fields(request_type=cloudtasks.GetQueueRequest) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_queue(request) @@ -7093,6 +7096,7 @@ def test_get_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_queue(**mock_args) @@ -7222,6 +7226,7 @@ def test_create_queue_rest_required_fields(request_type=cloudtasks.CreateQueueRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_queue(request) @@ -7276,6 +7281,7 @@ def test_create_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_queue(**mock_args) @@ -7403,6 +7409,7 @@ def test_update_queue_rest_required_fields(request_type=cloudtasks.UpdateQueueRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_queue(request) @@ -7451,6 +7458,7 @@ def test_update_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_queue(**mock_args) @@ -7578,6 +7586,7 @@ def test_delete_queue_rest_required_fields(request_type=cloudtasks.DeleteQueueRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_queue(request) @@ -7621,6 +7630,7 @@ def test_delete_queue_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_queue(**mock_args) @@ -7750,6 +7760,7 @@ def test_purge_queue_rest_required_fields(request_type=cloudtasks.PurgeQueueRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.purge_queue(request) @@ -7795,6 +7806,7 @@ def test_purge_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.purge_queue(**mock_args) @@ -7925,6 +7937,7 @@ def test_pause_queue_rest_required_fields(request_type=cloudtasks.PauseQueueRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.pause_queue(request) @@ -7970,6 +7983,7 @@ def test_pause_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.pause_queue(**mock_args) @@ -8100,6 +8114,7 @@ def test_resume_queue_rest_required_fields(request_type=cloudtasks.ResumeQueueRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.resume_queue(request) @@ -8145,6 +8160,7 @@ def test_resume_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.resume_queue(**mock_args) @@ -8275,6 +8291,7 @@ def test_get_iam_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_iam_policy(request) @@ -8320,6 +8337,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_iam_policy(**mock_args) @@ -8450,6 +8468,7 @@ def test_set_iam_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_iam_policy(request) @@ -8503,6 +8522,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.set_iam_policy(**mock_args) @@ -8641,6 +8661,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.test_iam_permissions(request) @@ -8695,6 +8716,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.test_iam_permissions(**mock_args) @@ -8833,6 +8855,7 @@ def test_list_tasks_rest_required_fields(request_type=cloudtasks.ListTasksReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_tasks(request) @@ -8887,6 +8910,7 @@ def test_list_tasks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_tasks(**mock_args) @@ -9079,6 +9103,7 @@ def test_get_task_rest_required_fields(request_type=cloudtasks.GetTaskRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_task(request) @@ -9126,6 +9151,7 @@ def test_get_task_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_task(**mock_args) @@ -9256,6 +9282,7 @@ def test_create_task_rest_required_fields(request_type=cloudtasks.CreateTaskRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_task(request) @@ -9310,6 +9337,7 @@ def test_create_task_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_task(**mock_args) @@ -9437,6 +9465,7 @@ def test_delete_task_rest_required_fields(request_type=cloudtasks.DeleteTaskRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_task(request) @@ -9482,6 +9511,7 @@ def test_delete_task_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_task(**mock_args) @@ -9612,6 +9642,7 @@ def test_run_task_rest_required_fields(request_type=cloudtasks.RunTaskRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.run_task(request) @@ -9659,6 +9690,7 @@ def test_run_task_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.run_task(**mock_args) @@ -10615,6 +10647,7 @@ def test_list_queues_rest_bad_request(request_type=cloudtasks.ListQueuesRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_queues(request) @@ -10650,6 +10683,7 @@ def test_list_queues_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_queues(request) # Establish that the response is the type that we expect. @@ -10688,6 +10722,7 @@ def test_list_queues_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudtasks.ListQueuesResponse.to_json( cloudtasks.ListQueuesResponse() ) @@ -10732,6 +10767,7 @@ def test_get_queue_rest_bad_request(request_type=cloudtasks.GetQueueRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_queue(request) @@ -10768,6 +10804,7 @@ def test_get_queue_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_queue(request) # Establish that the response is the type that we expect. @@ -10807,6 +10844,7 @@ def test_get_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = queue.Queue.to_json(queue.Queue()) req.return_value.content = return_value @@ -10849,6 +10887,7 @@ def test_create_queue_rest_bad_request(request_type=cloudtasks.CreateQueueReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_queue(request) @@ -10976,6 +11015,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_queue(request) # Establish that the response is the type that we expect. @@ -11015,6 +11055,7 @@ def test_create_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gct_queue.Queue.to_json(gct_queue.Queue()) req.return_value.content = return_value @@ -11059,6 +11100,7 @@ def test_update_queue_rest_bad_request(request_type=cloudtasks.UpdateQueueReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_queue(request) @@ -11188,6 +11230,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_queue(request) # Establish that the response is the type that we expect. @@ -11227,6 +11270,7 @@ def test_update_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gct_queue.Queue.to_json(gct_queue.Queue()) req.return_value.content = return_value @@ -11269,6 +11313,7 @@ def test_delete_queue_rest_bad_request(request_type=cloudtasks.DeleteQueueReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_queue(request) @@ -11299,6 +11344,7 @@ def test_delete_queue_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_queue(request) # Establish that the response is the type that we expect. @@ -11333,6 +11379,7 @@ def test_delete_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cloudtasks.DeleteQueueRequest() metadata = [ @@ -11371,6 +11418,7 @@ def test_purge_queue_rest_bad_request(request_type=cloudtasks.PurgeQueueRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.purge_queue(request) @@ -11407,6 +11455,7 @@ def test_purge_queue_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.purge_queue(request) # Establish that the response is the type that we expect. @@ -11446,6 +11495,7 @@ def test_purge_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = queue.Queue.to_json(queue.Queue()) req.return_value.content = return_value @@ -11488,6 +11538,7 @@ def test_pause_queue_rest_bad_request(request_type=cloudtasks.PauseQueueRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.pause_queue(request) @@ -11524,6 +11575,7 @@ def test_pause_queue_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.pause_queue(request) # Establish that the response is the type that we expect. @@ -11563,6 +11615,7 @@ def test_pause_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = queue.Queue.to_json(queue.Queue()) req.return_value.content = return_value @@ -11605,6 +11658,7 @@ def test_resume_queue_rest_bad_request(request_type=cloudtasks.ResumeQueueReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.resume_queue(request) @@ -11641,6 +11695,7 @@ def test_resume_queue_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.resume_queue(request) # Establish that the response is the type that we expect. @@ -11680,6 +11735,7 @@ def test_resume_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = queue.Queue.to_json(queue.Queue()) req.return_value.content = return_value @@ -11724,6 +11780,7 @@ def test_get_iam_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_iam_policy(request) @@ -11757,6 +11814,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_iam_policy(request) # Establish that the response is the type that we expect. @@ -11796,6 +11854,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(policy_pb2.Policy()) req.return_value.content = return_value @@ -11840,6 +11899,7 @@ def test_set_iam_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.set_iam_policy(request) @@ -11873,6 +11933,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -11912,6 +11973,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(policy_pb2.Policy()) req.return_value.content = return_value @@ -11956,6 +12018,7 @@ def test_test_iam_permissions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.test_iam_permissions(request) @@ -11988,6 +12051,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -12026,6 +12090,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -12070,6 +12135,7 @@ def test_list_tasks_rest_bad_request(request_type=cloudtasks.ListTasksRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_tasks(request) @@ -12105,6 +12171,7 @@ def test_list_tasks_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_tasks(request) # Establish that the response is the type that we expect. @@ -12143,6 +12210,7 @@ def test_list_tasks_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudtasks.ListTasksResponse.to_json( cloudtasks.ListTasksResponse() ) @@ -12189,6 +12257,7 @@ def test_get_task_rest_bad_request(request_type=cloudtasks.GetTaskRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_task(request) @@ -12229,6 +12298,7 @@ def test_get_task_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_task(request) # Establish that the response is the type that we expect. @@ -12270,6 +12340,7 @@ def test_get_task_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = task.Task.to_json(task.Task()) req.return_value.content = return_value @@ -12312,6 +12383,7 @@ def test_create_task_rest_bad_request(request_type=cloudtasks.CreateTaskRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_task(request) @@ -12350,6 +12422,7 @@ def test_create_task_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_task(request) # Establish that the response is the type that we expect. @@ -12391,6 +12464,7 @@ def test_create_task_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gct_task.Task.to_json(gct_task.Task()) req.return_value.content = return_value @@ -12435,6 +12509,7 @@ def test_delete_task_rest_bad_request(request_type=cloudtasks.DeleteTaskRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_task(request) @@ -12467,6 +12542,7 @@ def test_delete_task_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_task(request) # Establish that the response is the type that we expect. @@ -12501,6 +12577,7 @@ def test_delete_task_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cloudtasks.DeleteTaskRequest() metadata = [ @@ -12541,6 +12618,7 @@ def test_run_task_rest_bad_request(request_type=cloudtasks.RunTaskRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.run_task(request) @@ -12581,6 +12659,7 @@ def test_run_task_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.run_task(request) # Establish that the response is the type that we expect. @@ -12622,6 +12701,7 @@ def test_run_task_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = task.Task.to_json(task.Task()) req.return_value.content = return_value @@ -12666,6 +12746,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq response_value.status_code = 400 response_value.request = Request() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_location(request) @@ -12696,6 +12777,7 @@ def test_get_location_rest(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_location(request) @@ -12724,6 +12806,7 @@ def test_list_locations_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_locations(request) @@ -12754,6 +12837,7 @@ def test_list_locations_rest(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_locations(request) diff --git a/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py b/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py index b8627917533f..abfc21d9a221 100644 --- a/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py +++ b/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py @@ -8291,6 +8291,7 @@ def test_list_queues_rest_required_fields(request_type=cloudtasks.ListQueuesRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_queues(request) @@ -8346,6 +8347,7 @@ def test_list_queues_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_queues(**mock_args) @@ -8538,6 +8540,7 @@ def test_get_queue_rest_required_fields(request_type=cloudtasks.GetQueueRequest) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_queue(request) @@ -8583,6 +8586,7 @@ def test_get_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_queue(**mock_args) @@ -8713,6 +8717,7 @@ def test_create_queue_rest_required_fields(request_type=cloudtasks.CreateQueueRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_queue(request) @@ -8767,6 +8772,7 @@ def test_create_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_queue(**mock_args) @@ -8895,6 +8901,7 @@ def test_update_queue_rest_required_fields(request_type=cloudtasks.UpdateQueueRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_queue(request) @@ -8943,6 +8950,7 @@ def test_update_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_queue(**mock_args) @@ -9070,6 +9078,7 @@ def test_delete_queue_rest_required_fields(request_type=cloudtasks.DeleteQueueRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_queue(request) @@ -9113,6 +9122,7 @@ def test_delete_queue_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_queue(**mock_args) @@ -9243,6 +9253,7 @@ def test_purge_queue_rest_required_fields(request_type=cloudtasks.PurgeQueueRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.purge_queue(request) @@ -9288,6 +9299,7 @@ def test_purge_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.purge_queue(**mock_args) @@ -9418,6 +9430,7 @@ def test_pause_queue_rest_required_fields(request_type=cloudtasks.PauseQueueRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.pause_queue(request) @@ -9463,6 +9476,7 @@ def test_pause_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.pause_queue(**mock_args) @@ -9593,6 +9607,7 @@ def test_resume_queue_rest_required_fields(request_type=cloudtasks.ResumeQueueRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.resume_queue(request) @@ -9638,6 +9653,7 @@ def test_resume_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.resume_queue(**mock_args) @@ -9778,6 +9794,7 @@ def test_get_iam_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_iam_policy(request) @@ -9823,6 +9840,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_iam_policy(**mock_args) @@ -9953,6 +9971,7 @@ def test_set_iam_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_iam_policy(request) @@ -10006,6 +10025,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.set_iam_policy(**mock_args) @@ -10144,6 +10164,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.test_iam_permissions(request) @@ -10198,6 +10219,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.test_iam_permissions(**mock_args) @@ -10336,6 +10358,7 @@ def test_list_tasks_rest_required_fields(request_type=cloudtasks.ListTasksReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_tasks(request) @@ -10390,6 +10413,7 @@ def test_list_tasks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_tasks(**mock_args) @@ -10582,6 +10606,7 @@ def test_get_task_rest_required_fields(request_type=cloudtasks.GetTaskRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_task(request) @@ -10629,6 +10654,7 @@ def test_get_task_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_task(**mock_args) @@ -10759,6 +10785,7 @@ def test_create_task_rest_required_fields(request_type=cloudtasks.CreateTaskRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_task(request) @@ -10813,6 +10840,7 @@ def test_create_task_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_task(**mock_args) @@ -10940,6 +10968,7 @@ def test_delete_task_rest_required_fields(request_type=cloudtasks.DeleteTaskRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_task(request) @@ -10985,6 +11014,7 @@ def test_delete_task_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_task(**mock_args) @@ -11115,6 +11145,7 @@ def test_lease_tasks_rest_required_fields(request_type=cloudtasks.LeaseTasksRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.lease_tasks(request) @@ -11169,6 +11200,7 @@ def test_lease_tasks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.lease_tasks(**mock_args) @@ -11301,6 +11333,7 @@ def test_acknowledge_task_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.acknowledge_task(request) @@ -11355,6 +11388,7 @@ def test_acknowledge_task_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.acknowledge_task(**mock_args) @@ -11486,6 +11520,7 @@ def test_renew_lease_rest_required_fields(request_type=cloudtasks.RenewLeaseRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.renew_lease(request) @@ -11544,6 +11579,7 @@ def test_renew_lease_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.renew_lease(**mock_args) @@ -11676,6 +11712,7 @@ def test_cancel_lease_rest_required_fields(request_type=cloudtasks.CancelLeaseRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.cancel_lease(request) @@ -11732,6 +11769,7 @@ def test_cancel_lease_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.cancel_lease(**mock_args) @@ -11863,6 +11901,7 @@ def test_run_task_rest_required_fields(request_type=cloudtasks.RunTaskRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.run_task(request) @@ -11910,6 +11949,7 @@ def test_run_task_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.run_task(**mock_args) @@ -13109,6 +13149,7 @@ def test_list_queues_rest_bad_request(request_type=cloudtasks.ListQueuesRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_queues(request) @@ -13144,6 +13185,7 @@ def test_list_queues_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_queues(request) # Establish that the response is the type that we expect. @@ -13182,6 +13224,7 @@ def test_list_queues_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudtasks.ListQueuesResponse.to_json( cloudtasks.ListQueuesResponse() ) @@ -13226,6 +13269,7 @@ def test_get_queue_rest_bad_request(request_type=cloudtasks.GetQueueRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_queue(request) @@ -13262,6 +13306,7 @@ def test_get_queue_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_queue(request) # Establish that the response is the type that we expect. @@ -13301,6 +13346,7 @@ def test_get_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = queue.Queue.to_json(queue.Queue()) req.return_value.content = return_value @@ -13343,6 +13389,7 @@ def test_create_queue_rest_bad_request(request_type=cloudtasks.CreateQueueReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_queue(request) @@ -13504,6 +13551,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_queue(request) # Establish that the response is the type that we expect. @@ -13543,6 +13591,7 @@ def test_create_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gct_queue.Queue.to_json(gct_queue.Queue()) req.return_value.content = return_value @@ -13587,6 +13636,7 @@ def test_update_queue_rest_bad_request(request_type=cloudtasks.UpdateQueueReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_queue(request) @@ -13750,6 +13800,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_queue(request) # Establish that the response is the type that we expect. @@ -13789,6 +13840,7 @@ def test_update_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gct_queue.Queue.to_json(gct_queue.Queue()) req.return_value.content = return_value @@ -13831,6 +13883,7 @@ def test_delete_queue_rest_bad_request(request_type=cloudtasks.DeleteQueueReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_queue(request) @@ -13861,6 +13914,7 @@ def test_delete_queue_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_queue(request) # Establish that the response is the type that we expect. @@ -13895,6 +13949,7 @@ def test_delete_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cloudtasks.DeleteQueueRequest() metadata = [ @@ -13933,6 +13988,7 @@ def test_purge_queue_rest_bad_request(request_type=cloudtasks.PurgeQueueRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.purge_queue(request) @@ -13969,6 +14025,7 @@ def test_purge_queue_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.purge_queue(request) # Establish that the response is the type that we expect. @@ -14008,6 +14065,7 @@ def test_purge_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = queue.Queue.to_json(queue.Queue()) req.return_value.content = return_value @@ -14050,6 +14108,7 @@ def test_pause_queue_rest_bad_request(request_type=cloudtasks.PauseQueueRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.pause_queue(request) @@ -14086,6 +14145,7 @@ def test_pause_queue_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.pause_queue(request) # Establish that the response is the type that we expect. @@ -14125,6 +14185,7 @@ def test_pause_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = queue.Queue.to_json(queue.Queue()) req.return_value.content = return_value @@ -14167,6 +14228,7 @@ def test_resume_queue_rest_bad_request(request_type=cloudtasks.ResumeQueueReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.resume_queue(request) @@ -14203,6 +14265,7 @@ def test_resume_queue_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.resume_queue(request) # Establish that the response is the type that we expect. @@ -14242,6 +14305,7 @@ def test_resume_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = queue.Queue.to_json(queue.Queue()) req.return_value.content = return_value @@ -14298,6 +14362,7 @@ def test_get_iam_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_iam_policy(request) @@ -14331,6 +14396,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_iam_policy(request) # Establish that the response is the type that we expect. @@ -14370,6 +14436,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(policy_pb2.Policy()) req.return_value.content = return_value @@ -14414,6 +14481,7 @@ def test_set_iam_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.set_iam_policy(request) @@ -14447,6 +14515,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -14486,6 +14555,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(policy_pb2.Policy()) req.return_value.content = return_value @@ -14530,6 +14600,7 @@ def test_test_iam_permissions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.test_iam_permissions(request) @@ -14562,6 +14633,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -14600,6 +14672,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -14644,6 +14717,7 @@ def test_list_tasks_rest_bad_request(request_type=cloudtasks.ListTasksRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_tasks(request) @@ -14679,6 +14753,7 @@ def test_list_tasks_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_tasks(request) # Establish that the response is the type that we expect. @@ -14717,6 +14792,7 @@ def test_list_tasks_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudtasks.ListTasksResponse.to_json( cloudtasks.ListTasksResponse() ) @@ -14763,6 +14839,7 @@ def test_get_task_rest_bad_request(request_type=cloudtasks.GetTaskRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_task(request) @@ -14801,6 +14878,7 @@ def test_get_task_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_task(request) # Establish that the response is the type that we expect. @@ -14840,6 +14918,7 @@ def test_get_task_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = task.Task.to_json(task.Task()) req.return_value.content = return_value @@ -14882,6 +14961,7 @@ def test_create_task_rest_bad_request(request_type=cloudtasks.CreateTaskRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_task(request) @@ -14918,6 +14998,7 @@ def test_create_task_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_task(request) # Establish that the response is the type that we expect. @@ -14957,6 +15038,7 @@ def test_create_task_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gct_task.Task.to_json(gct_task.Task()) req.return_value.content = return_value @@ -15001,6 +15083,7 @@ def test_delete_task_rest_bad_request(request_type=cloudtasks.DeleteTaskRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_task(request) @@ -15033,6 +15116,7 @@ def test_delete_task_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_task(request) # Establish that the response is the type that we expect. @@ -15067,6 +15151,7 @@ def test_delete_task_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cloudtasks.DeleteTaskRequest() metadata = [ @@ -15105,6 +15190,7 @@ def test_lease_tasks_rest_bad_request(request_type=cloudtasks.LeaseTasksRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.lease_tasks(request) @@ -15138,6 +15224,7 @@ def test_lease_tasks_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.lease_tasks(request) # Establish that the response is the type that we expect. @@ -15175,6 +15262,7 @@ def test_lease_tasks_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudtasks.LeaseTasksResponse.to_json( cloudtasks.LeaseTasksResponse() ) @@ -15223,6 +15311,7 @@ def test_acknowledge_task_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.acknowledge_task(request) @@ -15255,6 +15344,7 @@ def test_acknowledge_task_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.acknowledge_task(request) # Establish that the response is the type that we expect. @@ -15291,6 +15381,7 @@ def test_acknowledge_task_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cloudtasks.AcknowledgeTaskRequest() metadata = [ @@ -15331,6 +15422,7 @@ def test_renew_lease_rest_bad_request(request_type=cloudtasks.RenewLeaseRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.renew_lease(request) @@ -15369,6 +15461,7 @@ def test_renew_lease_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.renew_lease(request) # Establish that the response is the type that we expect. @@ -15408,6 +15501,7 @@ def test_renew_lease_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = task.Task.to_json(task.Task()) req.return_value.content = return_value @@ -15452,6 +15546,7 @@ def test_cancel_lease_rest_bad_request(request_type=cloudtasks.CancelLeaseReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.cancel_lease(request) @@ -15490,6 +15585,7 @@ def test_cancel_lease_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.cancel_lease(request) # Establish that the response is the type that we expect. @@ -15529,6 +15625,7 @@ def test_cancel_lease_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = task.Task.to_json(task.Task()) req.return_value.content = return_value @@ -15573,6 +15670,7 @@ def test_run_task_rest_bad_request(request_type=cloudtasks.RunTaskRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.run_task(request) @@ -15611,6 +15709,7 @@ def test_run_task_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.run_task(request) # Establish that the response is the type that we expect. @@ -15650,6 +15749,7 @@ def test_run_task_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = task.Task.to_json(task.Task()) req.return_value.content = return_value @@ -15694,6 +15794,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq response_value.status_code = 400 response_value.request = Request() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_location(request) @@ -15724,6 +15825,7 @@ def test_get_location_rest(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_location(request) @@ -15752,6 +15854,7 @@ def test_list_locations_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_locations(request) @@ -15782,6 +15885,7 @@ def test_list_locations_rest(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_locations(request) diff --git a/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py b/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py index 9125c4cb7134..3fbd6ada1ed1 100644 --- a/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py +++ b/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py @@ -6830,6 +6830,7 @@ def test_list_queues_rest_required_fields(request_type=cloudtasks.ListQueuesRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_queues(request) @@ -6885,6 +6886,7 @@ def test_list_queues_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_queues(**mock_args) @@ -7077,6 +7079,7 @@ def test_get_queue_rest_required_fields(request_type=cloudtasks.GetQueueRequest) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_queue(request) @@ -7122,6 +7125,7 @@ def test_get_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_queue(**mock_args) @@ -7252,6 +7256,7 @@ def test_create_queue_rest_required_fields(request_type=cloudtasks.CreateQueueRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_queue(request) @@ -7306,6 +7311,7 @@ def test_create_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_queue(**mock_args) @@ -7434,6 +7440,7 @@ def test_update_queue_rest_required_fields(request_type=cloudtasks.UpdateQueueRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_queue(request) @@ -7482,6 +7489,7 @@ def test_update_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_queue(**mock_args) @@ -7609,6 +7617,7 @@ def test_delete_queue_rest_required_fields(request_type=cloudtasks.DeleteQueueRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_queue(request) @@ -7652,6 +7661,7 @@ def test_delete_queue_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_queue(**mock_args) @@ -7782,6 +7792,7 @@ def test_purge_queue_rest_required_fields(request_type=cloudtasks.PurgeQueueRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.purge_queue(request) @@ -7827,6 +7838,7 @@ def test_purge_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.purge_queue(**mock_args) @@ -7957,6 +7969,7 @@ def test_pause_queue_rest_required_fields(request_type=cloudtasks.PauseQueueRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.pause_queue(request) @@ -8002,6 +8015,7 @@ def test_pause_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.pause_queue(**mock_args) @@ -8132,6 +8146,7 @@ def test_resume_queue_rest_required_fields(request_type=cloudtasks.ResumeQueueRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.resume_queue(request) @@ -8177,6 +8192,7 @@ def test_resume_queue_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.resume_queue(**mock_args) @@ -8307,6 +8323,7 @@ def test_get_iam_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_iam_policy(request) @@ -8352,6 +8369,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_iam_policy(**mock_args) @@ -8482,6 +8500,7 @@ def test_set_iam_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_iam_policy(request) @@ -8535,6 +8554,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.set_iam_policy(**mock_args) @@ -8673,6 +8693,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.test_iam_permissions(request) @@ -8727,6 +8748,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.test_iam_permissions(**mock_args) @@ -8865,6 +8887,7 @@ def test_list_tasks_rest_required_fields(request_type=cloudtasks.ListTasksReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_tasks(request) @@ -8919,6 +8942,7 @@ def test_list_tasks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_tasks(**mock_args) @@ -9111,6 +9135,7 @@ def test_get_task_rest_required_fields(request_type=cloudtasks.GetTaskRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_task(request) @@ -9158,6 +9183,7 @@ def test_get_task_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_task(**mock_args) @@ -9288,6 +9314,7 @@ def test_create_task_rest_required_fields(request_type=cloudtasks.CreateTaskRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_task(request) @@ -9342,6 +9369,7 @@ def test_create_task_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_task(**mock_args) @@ -9469,6 +9497,7 @@ def test_delete_task_rest_required_fields(request_type=cloudtasks.DeleteTaskRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_task(request) @@ -9514,6 +9543,7 @@ def test_delete_task_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_task(**mock_args) @@ -9644,6 +9674,7 @@ def test_run_task_rest_required_fields(request_type=cloudtasks.RunTaskRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.run_task(request) @@ -9691,6 +9722,7 @@ def test_run_task_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.run_task(**mock_args) @@ -10653,6 +10685,7 @@ def test_list_queues_rest_bad_request(request_type=cloudtasks.ListQueuesRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_queues(request) @@ -10688,6 +10721,7 @@ def test_list_queues_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_queues(request) # Establish that the response is the type that we expect. @@ -10726,6 +10760,7 @@ def test_list_queues_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudtasks.ListQueuesResponse.to_json( cloudtasks.ListQueuesResponse() ) @@ -10770,6 +10805,7 @@ def test_get_queue_rest_bad_request(request_type=cloudtasks.GetQueueRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_queue(request) @@ -10807,6 +10843,7 @@ def test_get_queue_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_queue(request) # Establish that the response is the type that we expect. @@ -10847,6 +10884,7 @@ def test_get_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = queue.Queue.to_json(queue.Queue()) req.return_value.content = return_value @@ -10889,6 +10927,7 @@ def test_create_queue_rest_bad_request(request_type=cloudtasks.CreateQueueReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_queue(request) @@ -11051,6 +11090,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_queue(request) # Establish that the response is the type that we expect. @@ -11091,6 +11131,7 @@ def test_create_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gct_queue.Queue.to_json(gct_queue.Queue()) req.return_value.content = return_value @@ -11135,6 +11176,7 @@ def test_update_queue_rest_bad_request(request_type=cloudtasks.UpdateQueueReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_queue(request) @@ -11299,6 +11341,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_queue(request) # Establish that the response is the type that we expect. @@ -11339,6 +11382,7 @@ def test_update_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gct_queue.Queue.to_json(gct_queue.Queue()) req.return_value.content = return_value @@ -11381,6 +11425,7 @@ def test_delete_queue_rest_bad_request(request_type=cloudtasks.DeleteQueueReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_queue(request) @@ -11411,6 +11456,7 @@ def test_delete_queue_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_queue(request) # Establish that the response is the type that we expect. @@ -11445,6 +11491,7 @@ def test_delete_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cloudtasks.DeleteQueueRequest() metadata = [ @@ -11483,6 +11530,7 @@ def test_purge_queue_rest_bad_request(request_type=cloudtasks.PurgeQueueRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.purge_queue(request) @@ -11520,6 +11568,7 @@ def test_purge_queue_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.purge_queue(request) # Establish that the response is the type that we expect. @@ -11560,6 +11609,7 @@ def test_purge_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = queue.Queue.to_json(queue.Queue()) req.return_value.content = return_value @@ -11602,6 +11652,7 @@ def test_pause_queue_rest_bad_request(request_type=cloudtasks.PauseQueueRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.pause_queue(request) @@ -11639,6 +11690,7 @@ def test_pause_queue_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.pause_queue(request) # Establish that the response is the type that we expect. @@ -11679,6 +11731,7 @@ def test_pause_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = queue.Queue.to_json(queue.Queue()) req.return_value.content = return_value @@ -11721,6 +11774,7 @@ def test_resume_queue_rest_bad_request(request_type=cloudtasks.ResumeQueueReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.resume_queue(request) @@ -11758,6 +11812,7 @@ def test_resume_queue_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.resume_queue(request) # Establish that the response is the type that we expect. @@ -11798,6 +11853,7 @@ def test_resume_queue_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = queue.Queue.to_json(queue.Queue()) req.return_value.content = return_value @@ -11842,6 +11898,7 @@ def test_get_iam_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_iam_policy(request) @@ -11875,6 +11932,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_iam_policy(request) # Establish that the response is the type that we expect. @@ -11914,6 +11972,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(policy_pb2.Policy()) req.return_value.content = return_value @@ -11958,6 +12017,7 @@ def test_set_iam_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.set_iam_policy(request) @@ -11991,6 +12051,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -12030,6 +12091,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(policy_pb2.Policy()) req.return_value.content = return_value @@ -12074,6 +12136,7 @@ def test_test_iam_permissions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.test_iam_permissions(request) @@ -12106,6 +12169,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -12144,6 +12208,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -12188,6 +12253,7 @@ def test_list_tasks_rest_bad_request(request_type=cloudtasks.ListTasksRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_tasks(request) @@ -12223,6 +12289,7 @@ def test_list_tasks_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_tasks(request) # Establish that the response is the type that we expect. @@ -12261,6 +12328,7 @@ def test_list_tasks_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudtasks.ListTasksResponse.to_json( cloudtasks.ListTasksResponse() ) @@ -12307,6 +12375,7 @@ def test_get_task_rest_bad_request(request_type=cloudtasks.GetTaskRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_task(request) @@ -12347,6 +12416,7 @@ def test_get_task_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_task(request) # Establish that the response is the type that we expect. @@ -12388,6 +12458,7 @@ def test_get_task_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = task.Task.to_json(task.Task()) req.return_value.content = return_value @@ -12430,6 +12501,7 @@ def test_create_task_rest_bad_request(request_type=cloudtasks.CreateTaskRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_task(request) @@ -12468,6 +12540,7 @@ def test_create_task_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_task(request) # Establish that the response is the type that we expect. @@ -12509,6 +12582,7 @@ def test_create_task_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gct_task.Task.to_json(gct_task.Task()) req.return_value.content = return_value @@ -12553,6 +12627,7 @@ def test_delete_task_rest_bad_request(request_type=cloudtasks.DeleteTaskRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_task(request) @@ -12585,6 +12660,7 @@ def test_delete_task_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_task(request) # Establish that the response is the type that we expect. @@ -12619,6 +12695,7 @@ def test_delete_task_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cloudtasks.DeleteTaskRequest() metadata = [ @@ -12659,6 +12736,7 @@ def test_run_task_rest_bad_request(request_type=cloudtasks.RunTaskRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.run_task(request) @@ -12699,6 +12777,7 @@ def test_run_task_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.run_task(request) # Establish that the response is the type that we expect. @@ -12740,6 +12819,7 @@ def test_run_task_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = task.Task.to_json(task.Task()) req.return_value.content = return_value @@ -12784,6 +12864,7 @@ def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationReq response_value.status_code = 400 response_value.request = Request() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_location(request) @@ -12814,6 +12895,7 @@ def test_get_location_rest(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_location(request) @@ -12842,6 +12924,7 @@ def test_list_locations_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_locations(request) @@ -12872,6 +12955,7 @@ def test_list_locations_rest(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_locations(request)